What is the Function? How can you use it?
The Function is a duty you want to run. When you click a button (MouseEvent) or a period of animation’s the time (TimerEvent) the function can work. You can give more than one value for the function.
You can write a standard function as follows;
function nameOfFunction ():void
{
trace("Hello")
}
nameOfFunction ()
if you want to send a value or values inside of the function you should determine type of the value (String, Number or MovieClip).
function nameOfFunction (newX:Number):void
{
trace(newX)
}
nameOfFunction (25)
if you want to calculate things (String or Number) to get back the result you should determine the class of the result instead of “void”.
function nameOfFunction (newX:Number):Number
{
var newNumber = newX * 3
return newNumber;
}
var figure:Number=nameOfFunction(25)
trace(figure)