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.
Its not really hidden (very obscured in the documentation), but updateAfterEvent is quite an unknown and useful method under certain circumstances...
In Flash Professional, you can change a MovieClip symbol to a Sprite by redirecting it's base class from
flash.display.MovieClip
toflash.display.Sprite
, and the symbol icon color in the library will change from blue to green.I'm sure you will find usefull this article by jpauclair: AS3 hidden treasure in the mm.cfg file
[Flash IDE]
This isn't a feature as much as it is a gotcha. When specifying a document class for an FLA, the compiler does not subclass that class, it modifies it.
This can cause problems when you have several SWFs with the same document class, all being loaded into another SWF (since two classes with the same name cannot be loaded side-by-side into the same application domain). It results in the first being loaded and the second using the first's modified class, producing weird errors (as you can imagine).
The solution is either:
Well this might not be a hidden feature but maybe people have missed that there are external tweening engines you can use. My latest favourite is Greensocks. The only thing in my opinion it has lacked seems to be improving, workflow. Have not tested v.11 yet but definitely will on my next AS project: http://blog.greensock.com/v11beta/
ActionScript 2
every class is a function and every function a class ... AS2 is prototype based ...
accessing
Function::prototype
allows extending classes at runtime:Object::__proto__
... allows you to change the prototype of an object, which can be used for runtime reclassing:in this example, the function
trace
is reclassed to Array ... pretty cool, huh? :)Function::apply
andFunction::call
allow applying any function as a method to any object:using the three above, instantiation of a class
MyClass
with parametersparam_1, ..., param_n
can be written as:a corelation of
Function::push
andFunction::apply
is thatthis
is simply a function argument, that is passed automatically ... as any other function argument, it can be written to ...Object::__resolve
... settings this method allows you to react to lookups on undefined properties ... this is fun and useful for proxying, mocking, composition, delegation, and so on ...that's it for now ... there's an awfull lot more ... the thing is simply, that AS2 is an exiting language, but painfully slow ... AS3 in comparison is boring as hell, but the speed increase is really great ...
greetz
back2dos