About functions and methods
217
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
NO
TE
For information on writing code using Script Assist, see
“Using Script Assist to write
ActionScript” on page 328
,
“Creating a startDrag/stopDrag event using Script
Assist” on page 331
and the ActionScript:Use Script Assist Mode tutorial (which
begins with
“Open the starter document” on page 213
).
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...