Comments


Comments are lines of code the ActionScript reader skips over, but they are visible to people who open the file in the authoring environment. Comments are used to tell the story of ActionScript to the next person who looks at your code, (or to tell yourself later if you have to go back into the file). They are placed with variables to tell what those variables are used for. Comments are placed with functions to tell what the parameters are and what should go in them. And they are used to help narrow down bugs in code by commenting out specific lines.

To make a comment, you simply put two forward slashes (//) in front of your comment like this:

 //this is a comment 

You can put comments on their own line like the preceding one, or you can put them at the end of a line after some code, like these:

 this.stop(); //this stops the movie clip var name:String = "David" //declares a variable function myFunction (){ //start of a function      this.stop();    //the guts of a function }                //the end of a function 

You can even comment out several lines at once using /* at the beginning and */ at the end of the comment like this:

 /* this entire section is commented I know, because I commented it ok, that's enough... */ 

And as mentioned, they are used to tell someone looking at your ActionScript (including yourself) what the code is doing and why.

You can also comment out lines of code for debugging as previously mentioned, like this:

 this.stop(); function myFunction(){      this.gotoAndStop(2);      myVariable = 15; //     myNumber = myVariable/Math.PI; } 

Notice that when you put the comment in front of the line of code, it changes the entire line's color, meaning that the ActionScript reader will skip it because it is now a comment.

Another very important point is naming conventions.




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net