| 
			
			 | 
			
			
				
					
					
 
Naming Conventions 
      
by ilyas usal | 27 
December 2005The 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 
usually proceed: 
	- 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 
	it out. 
	- 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 (startDrag, 
	swapDepths, nextFrame). 
	- Object name: DaObject
 
	Objects are capitalized. So are constructors. Instances of a class, on the 
	other hand, begin with a lower case letter. 
	 
 
	
		
			- MyClass=function(){};
			// constructor 
 
			- aClass=new
			MyClass();
			// instance 
 
		 
	 
 
	- Constant name: MAXCLIP
 It is common practice to put constant names all upper case. Even if I never 
	do it. 
	- 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,
		
function, if, 
		while, for...),
		case, var, 
		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. 
 
	 
	
		
			8count=0; 
			// forbidden 
		 
	 
	
		- Variables beginning with an underscore are usually object 
		properties, so it's not a good idea to give your variables names like
		
_count. 
		 
	 
	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 
	or another. 
  
		- First way: use a prefix
 
		If you have a movie clip of a line, call it
		mcLine. 
		If it's an input string, make it
		sInput, 
		an array of points
		aPoints 
		and so on for the other types (textfield, 
		date, sound, XML, color). 
		- Second way: use a suffix
 
		With the same examples, you'd have something like that:
		line_mc, 
		input_str, points_arr  
	 
	 
 
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. 
 
- pom 
   | 
				 
				
					
					  | 
				 
			 
			 | 
			
			
			 |