Feb 01

Flex vs Javascript

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)

  1. (Binary Trees) – nothing to add here
  2. (Concat Performance) – counterintuitively, ActionScript is almost twice as fast with concatenation as it is with Array.join
  3. (Binding Objects To Methods) – works exactly the same in AS3 as JavaScript
  4. (Custom Sort Functions) – works exactly the same way in AS3 as JavaScript
  5. (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.
  6. (Static Variables) – ActionScript 3 has native support for static variables
  7. (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.
  8. (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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>