Guys, I am thoroughly surprised that there is no Flash Hidden Features post yet in the Hidden Features series that I've been tracking for a while now.
There is a recent AS3/Flex one but it's not very active and I don't exactly mean just AS3 when I say Flash here.
The Hidden Features series is great for people who are new to a certain language. It shows the ropes and certain valuable tricks, all in one place. I think it's a brilliant idea. Even experts sometimes find tricks they'd never heard about.
When I started with Flash, I was taken aback by the Flash IDE and odd concepts of Flash, compared to other programming languages.
So, here goes: what are some hidden features of Flash as a language (AS2/3) and the Flash IDE?
Let the fun begin.
[AS3]
I wouldn't necessarily call this a 'feature', but you can actually access variables before they are defined (even with strict compilation) due to the way the compiler works:
It can actually lead to frustration when refactoring code (since it compiles).
when using flashvars write a utility method getFlashVars().
}
then when I'm coding I always add an extra || so that I won't have to flashvars while debugging.
Here's another gotcha:
By default Flash tools strips any metadata tags that you have. Many frameworks depends on these metadata tags. What you need to be careful is that this doesn't only apply to the compiler, but also to the optimizer. Be sure to run both your compiler and optimizer with -keep-as3-metadata-tag option to keep your metadata tag in there.
[AS3]
When looking for a the value of a variable, the player will run up the scope chain until it finds what it's looking for. So using nested (anonymous) functions you do things like make asynchronous calls and handle it using variables that were defined on the scope of the calling method. e.g.
Loads of other uses for this and it's really very useful
[as3]
prototype based inheritance :
[AS3] Tips for working with arrays or Vectors
Fastest way through an array, always from the back
Clearing an array,
Pushing and splicing
Cloning