192
Syntax and Language Fundamentals
To use the greater than or equal to operator in your code:
1.
Select File > New and then select Flash Document to create a new FLA file.
2.
Add the following code to Frame 1 of the main Timeline:
this.createTextField("myTxt", 20, 0, 0, 100, 20);
myTxt.type = "input";
myTxt.border = true;
myTxt.restrict = "0-9";
this.createEmptyMovieClip("submit_mc", 30);
submit_mc.beginFill(0xFF0000);
submit_mc.moveTo(0, 0);
submit_mc.lineTo(100, 0);
submit_mc.lineTo(100, 20);
submit_mc.lineTo(0, 20);
submit_mc.lineTo(0, 0);
submit_mc.endFill();
submit_mc._x = 110;
submit_mc.onRelease = function(evt_obj:Object):Void {
var myNum:Number = Number(myTxt.text);
if (isNaN(myNum)) {
trace("Please enter a number");
return;
}
if (myNum >= 10) {
trace("Your number is greater than or equal to 10");
} else {
trace("Your number is less than 10");
}
};
3.
Select Control > Test Movie to test the ActionScript.
You can also check whether certain conditions are true and execute an alternative block if
the condition is not true.
4.
Change the condition in your ActionScript to the following.
if (myNum == 10) {
trace("Your number is 10");
} else {
trace("Your number is not 10");
}
5.
Select Control > Test Movie to test the ActionScript again.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...