MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 217

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

return Number.NaN;
}
num_array.sort(Array.NUMERIC | Array.DESCENDING);
var min:Number = Number(num_array.pop());
return min;
}
public static function arrayMax(num_array:Array):Number {
if (num_array.length == 0) {
return undefined;
}
num_array.sort(Array.NUMERIC);
var max:Number = Number(num_array.pop());
return max;
}
}
3.
Select File > Save to save the ActionScript file.
4.
Create a new Flash document and save it as classFunctions.fla in the same directory
as Utils.as.
5.
Select Window > Actions to open the Actions panel.
6.
Type the following ActionScript into the Script pane:
var randomMonth:Number = Utils.randomRange(0, 11);
var min:Number = Utils.arrayMin([3, 3, 5, 34, 2, 1, 1, -3]);
var max:Number = Utils.arrayMax([3, 3, 5, 34, 2, 1, 1, -3]);
trace("month: " + randomMonth);
trace("min: " + min); // -3
trace("max: " + max); // 34
7.
Select Control > Test Movie to test the documents. The following text is displayed in the
Output panel:
month: 7
min: -3
max: 34
For information on writing code using Script Assist, see
ActionScript" on page
Assist" on page 331
begins with
328,
"Creating a startDrag/stopDrag event using Script
and the ActionScript:Use Script Assist Mode tutorial (which
"Open the starter document" on page
"Using Script Assist to write
213).
About functions and methods
217

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents