Square Bracket Syntax & Typecasting

Actionscript:
  1. addChild(new TextField());
  2. getChildAt(0)["text"] = "Hello World";

Notice that square bracket syntax makes it so we don't need to typecast. Take a look at the other way:

Actionscript:
  1. addChild(new TextField());
  2. TextField(getChildAt(0)).text = "Hello World";

Typecasting is the way to go.... the square bracket technique is just an interesting trick.

I wrote this after somehow stumbling on this very entertaining page - it shows hello world written in approximately 200 different languages...

This entry was posted in dynamic, misc and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*