Functions
// FUNCTIONS
//First the function must be defined; the basic syntax looks like this:
function doSomething() {
//statements about what to do when the function is called
trace ("Hello, I'm a function");
}
//Next, "call" the function when you want to run its statements.
doSomething();
//Add an argument and pass our function a value;
function myTrace(sayWhat:String) {
trace (sayWhat);
}
myTrace("Yo dude!");
myTrace("How are you doing?");
myTrace("I'm great!");
function resetClip(myClip:MovieClip, myMessage:String) {
myClip.x = Math.random() * 550;
myClip.y = 100;
myClip.alpha = .5;
myClip.scaleX = 2;
trace (myMessage);
//functions can return a value
return myClip.x;
}
resetClip(box_mc,"box reset");
resetClip(circle_mc, "circle reset");
//you can use trace to call the function and trace its returned value
trace (resetClip(box_mc, "box reset"));