【发布时间】:2015-06-15 01:14:12
【问题描述】:
我是 AS3 编程的新手。我想问如何停止这个齿轮动画。我只是做了一个停止旋转的功能,但事件不会停止。
import flash.events.MouseEvent;
var smallGearSpeed:Number = -2;
var bigGearSpeed:Number = 1;
btn_Normal.addEventListener(MouseEvent.CLICK, fl_rotateNormalHandler);
btn_Acc.addEventListener(MouseEvent.CLICK, fl_rotateAccHandler);
btn_Stop.addEventListener(MouseEvent.CLICK, fl_rotateStopHandler);
function fl_rotateStopHandler (evt:MouseEvent):void {
addEventListener(Event.ENTER_FRAME, fl_rotateStop);
}
function fl_rotateNormalHandler (evt:MouseEvent):void {
addEventListener(Event.ENTER_FRAME, fl_rotateNormal);
}
function fl_rotateAccHandler(evt:MouseEvent):void {
addEventListener(Event.ENTER_FRAME, fl_rotateAcc);
}
function fl_rotateNormal (evt:Event):void {
rotateNormal();
}
function fl_rotateAcc (evt:Event):void {
rotateAcc();
}
function fl_rotateStop (evt:Event):void {
rotateStop();
}
function rotateNormal():void {
mc_BigGear.rotation += bigGearSpeed;
mc_SmallGear.rotation += smallGearSpeed;
trace("Normal Clicked !!!");
}
function rotateAcc():void {
mc_BigGear.rotation += bigGearSpeed;
bigGearSpeed = bigGearSpeed + .1;
mc_SmallGear.rotation += smallGearSpeed;
smallGearSpeed = smallGearSpeed - .1;
trace("Accelerate Clicked !!!");
}
function rotateStop():void {
mc_BigGear.rotation = bigGearSpeed - 1;
mc_SmallGear.rotation = smallGearSpeed + 2;
trace("Stop Clicked !!!");
}
我希望有人能帮我解决这个问题。对不起我的英语不好,谢谢:)
【问题讨论】:
标签: actionscript-3 animation event-handling