ActionScript: Good practices in Flash Development
Posted on 11:19 AM
Here some tips and a list of good practices in Flash Development.
These tips are usefull for coders and designers.
Prepare your layers
When you create a new .fla file prepare your layers like this :
Add a new layers “Actions” on the top of the list. This layer will be dedicated to ActionScript.
Then lock this layer to avoid adding graphic elements here.
Lock the main script
In order to keep in sight your main script, I recommend to lock this script by clicking on the pin on the bottom of the Actions pannel like this :
Enabled the Flash debugger to display more efficient error messages.
File> Publish settings… > Permit debugging
You can find this kind of message if you got an execution error : (My Flash player is in french language)
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
This error is located on the 1st frame on line 3. So useful !
However you must uncheck this option before publishing your swf on the web.
Order you symbols and your medias in folders. Name your folders with explicit names.
Name your folders by using the prefix “_”.
This tip can keep all your folders in the top of the list.
And you can name a symbol or a media like your foler.
Example: _Ball Folder own the Ball symbol.
The library orders elements and folders by alphabetical order.
Your library is now more lisible.
Name your symbols and your medias correctly
When you name your symbols or you media, particularly MovieClips, Istrongly recommand using a capital letter on the first character.
When flash adds a new MovieClip with ActionScript he uses the class name exported for ActionScript.
By convention a class name has always a capital letter on the first character.
var mc = new BlueScreenOfTheDeath();
However the symbol name match with the class name when you link the symbol for ActionScript. So keep the same name.
ActionScript looks like Java so use the Java naming convention.