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]
The
||
(logical or) operator can be used for any truthy/falsey values.Also, you can use
&
and|
(bitwise and/or) to do a non-short-circuted expression:[AS3]
becomes slightly shorter by writing
You can even predefine values:
Here's something most people don't know: MouseEvents are tracked outside of the application window if the MOUSE_DOWN event has been fired, but not MOUSE_UP. You can grab mouse positions outside of the application window (and even outside of the browser window) as long as whatever you're doing makes the user hold their mouse down. To test this, try running the following code:
This package will get you all the DisplayObjects in DisplayObjectContainer by setting class types.
Note: It wont count frames in MovieClips.
MovieClip.addFrameScript() is a undocumented ActionScript 3.0 feature that allows you to specify a function that is called when the playhead of the Movieclip timeline enters a particular frame number.
The frame number is zero based (1st frame = 0) and needs to be whole numbers only, however if you wanted to use frame labels you could use something like this:
It's not documented anywhere, but a forum post explains more.