my1

Friday, April 13, 2012

Flash Tip: Commenting Out ActionScripts

One thing that’s essential to any scripting/programming language is the ability to add notes or inactivate code without affecting the existing code or deleting something that might be needed later. Various languages use various markers to identify comments; Flash ActionScripting is no exception.

To insert a comment in ActionScripted code, just put two backslashes (//) in front of it. So a comment explaining the function of a particular block of code might look like this:
//duplicate the snow movie clip up to 250 duplicates
dup = Math.random()*5;
for (dup=0; dup<250; dup++){
duplicateMovieClip(this.snowbit, “snowbit”+dup, dup) ;
}

Flash color-codes ActionScripts so that you can pick out keywords and determine active code; any comments will be grey, rather than black or blue.

Don’t forget, when you’re commenting out code to remove its functions from your compiled scripts, to comment out every line. If you just comment out the first line, Flash will read the rest of the code as valid but missing parameters, and you’ll get syntax errors and some rather unexpected results. Inactive code should be grey, and similar in format to this:
// onClipEvent (enterFrame) {
// pos = pos+(Math.random()*1) ;
// this._x = this._x+Math.sin(pos) ;
// this._y = this._y+1+Math.random()*5;
// if (this._y>600){
// this._y = this.y-650+Math.random()*600;
// this._x = -50+Math.random()*950;
// }
// }

You’ll notice that each individual line has the double backslash (//) in front of it.

To make code active again, just delete the double backslash.

1 comment:

  1. Hi, I just take a peek and I discovered your blog. I find your tips really good and appreciable. This can be a big help for me friend. Thank you .

    ReplyDelete