by ilyas usal | 27
The naming scheme of your movie is
very important for readability purposes. I mean that the type of the entity you
are referring to should be obvious just by looking at its name. Your best bet
then is to make your names phrases, or at least a series of words. Here's how I
- Movie name: my_movie_that_does_stuff.swf
I use a nice little sentence, everything lower case, with words separated by
underscores. Keeping track of what a movie contains is not an easy thing,
and giving them names like test01_b.swf will NOT help you to figure
- Function name: doSomething()
Function names usually begin with a lower case letter. It is very common for
programmers to put a verb followed by a noun (first letter upper case). So
if your function is supposed to get the position of a clip, it would be a
good idea to call it
getPosition(). You'll notice that this is how Macromedia named its
own functions (
- Object name: DaObject
Objects are capitalized. So are constructors. Instances of a class, on the
other hand, begin with a lower case letter.
- Constant name: MAXCLIP
It is common practice to put constant names all upper case. Even if I never
- Variable name:
Variable names are a tiny bit more complicated. I'll start by what they
should not be, and then will see the best practices.
- Variable names should not be one of Flash reserved words: words that
are part of the language (function names,
switch, MovieClip.... I don't know the whole list, but if a
variable name turns blue, it's usually not a good sign.
- They should not begin with a number.
- Variables beginning with an underscore are usually object
properties, so it's not a good idea to give your variables names like
Now what you should do. This is not really critical, as Flash is not a
strongly typed language, but it's better to precise the type anyway, one way
- First way: use a prefix
If you have a movie clip of a line, call it
If it's an input string, make it
an array of points
and so on for the other types (
date, sound, XML, color).
- Second way: use a suffix
With the same examples, you'd have something like that:
There. That's about all I can think about. Once again, you don't HAVE TO use
all this, but if you do, your code will be easier to read for everybody.