I’ve been looking at 9 things you may not know about javaScript, and I thought it would be interesting (where appropriate) to see if ActionScript 3.0 shows the same behavior (where appropriate)
- (Binary Trees) - nothing to add here
- (Concat Performance) - counterintuitively, ActionScript is almost twice as fast with concatenation as it is with Array.join
- (Binding Objects To Methods) - works exactly the same in AS3 as JavaScript
- (Custom Sort Functions) - works exactly the same way in AS3 as JavaScript
- (AssertException) - similar. I created a seperate class, for clarity, and when you throw the exception it pops a message up on top of the app, which can be disruptive if you’re in production. I suppose you could turn off that behavior in production.
- (Static Variables) - ActionScript 3 has native support for static variables
- (Undefined, Null and Delete) - slight behavior change here. delete seems to remove a property, and both Alert.show() and Text.text reveal it as blank, instead of undefined.
- (Deep Nesting) - this one was the most significant difference - because everything in ActionScript3 is strongly typed, you can’t link a String to a TextInput.text element, for example. However, you can link objects to each other. For example:
if I have a Form a, with a FormItem b, and a TextInput c
I can do this:var linkTextInput:TextInput = c; // linkTextInput.text will always == c.text
But I can’t do this:
var textString:String = c.text; // if the user enters new text into c, textString will still contain the old text.
9. (FireBug) - there’s a built-in debugger in Flex, so none of this really applies.
Update: 2/2/07 - added #5, 6 and 7.
Update: 2/5/07 - added #8 and #9