588
Creating Interaction with ActionScript
Deconstructing a sample script
In the sample SWF file zapper.swf (which you can view in Using Flash Help), when a user
drags the bug to the electrical outlet, the bug falls and the outlet shakes. The main timeline
has only one frame and contains three objects: the ladybug, the outlet, and a reset button.
Each object is a movie clip instance.
The following script is attached to Frame 1 of the main Timeline:
var initx:Number = bug_mc._x;
var inity:Number = bug_mc._y;
var zapped:Boolean = false;
reset_btn.onRelease = function() {
zapped = false;
bug_mc._x = initx;
bug_mc._y = inity;
bug_mc._alpha = 100;
bug_mc._rotation = 0;
};
bug_mc.onPress = function() {
this.startDrag();
};
bug_mc.onRelease = function() {
this.stopDrag();
};
bug_mc.onEnterFrame = function() {
if (this.hitTest(this._parent.zapper_mc)) {
this.stopDrag();
zapped = true;
bug_mc._alpha = 75;
bug_mc._rotation = 20;
this._parent.zapper_mc.play();
}
if (zapped) {
bug_mc._y += 25;
}
};
Содержание 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...