Use Regular Expression to validate the Date

In one of my recent project, I need to check the user input of a Date field to see if he/she inputs a valid date. I did some search on Google and found this regular expression that works well:


In ActionScript, you write code like this to use the Regular Expression:

var pattern:RegExp = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/;
var str:String = "29/02/2010";
trace (pattern.test(str));


Super COOL AIR App: Scorekeeper

While I was walking around the internet this morning, I found this super COOL AIR app named ScoreKeeper created by tomkrcha on his blog. Check this video and visit the original article please. It’s sooooooooooo COOL!

Use StageVideo on Honeycomb

Since FlashPlay 10.2 and AIR 3.0, user can use StageVideo on all Honeycomb devices. But just like other new features provided by Adobe, you won’t just get it for free without any pain:)

I spent the whole morning to figure out how to make it happen on my Xoom. After reading dozens of threads from Adobe’s forum, finally, it worked. Here are something you need to prepare before the StageVideo servers you correctly:

  1. Make sure you are running on Honeycomb. Any Android OS lower than 3.0 doesn’t have StageVideo.
  2. In your Flex Compiler setting, make sure you have those values input: -swf-version=13 -target-player=11.0.0
  3. In your application description xml file, make sure you have the following setting:
    1. renderMode = direct
    2. colorDepth = 32bit [this one could be omitted if your app’s namespace is >= 3.0]

Those settings will give your the access of StageVideo. But if you want to actually SEE your video on the screen, you should make you application’s background transparent: backgroundAlpha=”0″. Otherwise, you will only hear the audio.

Now, you should have StageVideo serve you correctly:)

Google Swiffy又回来了

N久以前,我们见到过Swiffy,一个由Google工程师在20%时间项目上面开发的小工具,用来把swf转换成html。但听说Google把它给停了。今天又看到消息说它又回来了,而且作为一个Flash Pro的插件,直接在Flash Pro里运行,导出成html。目前的版本限制很多,但应该还是很有潜力的。具体的情况移步Google的博客吧。

Hey, try NativeText if StageText is too difficult to use

StageText gives the possibility to use native text input controller which has more powerful features like auto-complete. But sometime it is just too difficult to use. Some guys from Adobe gives a NativeText class which wraps the StageText and add some fancy features. Here is the description:

NativeText is a wrapper around StageText which makes adding native text input functionality to your ActionScript application much easier. NativeText has the following advantages:
  • It makes StageText feels like it’s part of the display list. You can create an instance of NativeText, give it x and ycoordinates, and add it to the display list just like you would any other display object. All the management of theviewPort is completely encapsulated.
  • It’s easy to add borders. NativeText does the work of drawing borders such that the StageText instance is vertically centered and horizontally bound. You can even change the border’s thickness, color, and corner radius.
  • It’s easy to add content on top because it manages the bitmap swapping for you. NativeText has a function calledfreeze which does all the work of drawing the StageText to a bitmap (including the border), hiding the StageText instance, and positioning the bitmap exactly where the StageText was. Therefore, if you want to place content on top of a NativeText instance (for instance, an alert box), just call the freeze function first, and everything will work perfectly. When you’re done, call unfreeze, and the bitmap is replaced with the StageText instance and disposed of.
  • Support for multi-line text inputs. NativeText supports text fields of one or more lines. Just pass the number of lines of text you want into the constructor (this is the one property that cannot be changed dynamically), and both the border and viewPort will be properly managed for you.
  • Cross platform. The trickiest part of writing NativeText was making sure it rendered properly on all our reference platforms (Mac, Windows, iOS, and Android) which use different fonts, have different sized cursors, etc. NativeText lets you use any font, font size, and border thickness you want, and your text input should render properly and consistently on all supported platforms.