User Guide
function 309
Example
The following example defines the function sqr, which accepts one parameter and returns the
Math.pow(x, 2)
of the parameter:
function sqr(x:Number) {
return Math.pow(x, 2);
}
var y:Number = sqr(3);
trace(y); // output: 9
If the function is defined and used in the same script, the function definition may appear after
using the function:
var y:Number = sqr(3);
trace(y); // output: 9
function sqr(x:Number) {
return Math.pow(x, 2);
}
The following function creates a LoadVars object and loads params.txt into the SWF file. When
the file successfully loads,
variables loaded traces:
var myLV:LoadVars = new LoadVars();
myLV.load("params.txt");
myLV.onLoad = function(success:Boolean) {
trace("variables loaded");
}