flash如何用鼠标控制旋转元件的暂停

来源:百度知道 编辑:UC知道 时间:2024/06/14 02:37:07
首先作了一个旋转的圆。主时间轴上代码如下:
onClipEvent (load) {
spd = 1;
}
onClipEvent (enterFrame) {
circle._rotation += spd;
}

现在我想要达到的效果是,当鼠标移到此圆上时,这个圆能够停止转动。但是由于有enterFrame事件,所以不知道该如何加代码呢
我知道要加stop来控制,但是有enterframe事件啊。

AS2.0,不太知道的。要是AS3.0就好了。

circle.addEventListener(Event.ENTER_FRAME,onEnterFrame);
circle.addEventListener(MouseEvent.ROLL_OVER,onRollOver);
circle.addEventListener(MouseEvent.ROLL_OUT,onRollOut);

function onEnterFrame(event:Event):void
{
event.target.rotation+=1;
}

function onRollOver(event:MouseEvent):void
{
circle.removeEventListener(Event.ENTER_FRAME,onEnterFrame);
}

function onRollOut(event:MouseEvent):void
{
circle.addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
//以上是AS3.0的写法,所以我觉得AS3.0写起来好耍啊。

如果,你一定要用AS2.0写,那么,你就不要写在元件上了,写在包含元件的帧里面,下面是AS2.0的内容:

circle.onLoad=init();
circle.onEnterFrame=rotationCircle;

function init(){
spd = 10;
}
function rotationCircle(){
circle._rotation += spd;
}

circle.onRollOver = function() {
delete circle.onEnterFrame;
};
circle.onRollOut=function()