0

如果有人帮助我进行一些编码,我会很感激。

我有这段代码,我以前可以用鼠标旋转电影剪辑,然后进入另一个帧,用于大学工作(我们只做了补间,刚刚学习了基本编码),但我无法得到任何结果。

import flash.events.Event;
import flash.events.MouseEvent;

knob_mc.addEventListener(MouseEvent.MOUSE_DOWN, rotate);
stage.addEventListener(MouseEvent.MOUSE_UP, endrotate );
var angle:Number=0

function rotate(e:Event):void
{
    stage.addEventListener(MouseEvent.MOUSE_MOVE,rotate);


    var position:Number = Math.atan2(mouseY - knob_mc.y,mouseX - knob_mc.x);


    angle=(position/Math.PI) *180;
    knob_mc.rotation = angle;

}

function endrotate(e:MouseEvent):void
{
    knob_mc.removeEventListener(MouseEvent.MOUSE_DOWN, rotate);
    stage.removeEventListener(MouseEvent.MOUSE_UP, menu);
    stage.removeEventListener(MouseEvent.MOUSE_MOVE,rotate);
    knob_mc.addEventListener(MouseEvent.MOUSE_DOWN,rotate);
}

function menu(e:MouseEvent):void
{
    if ( angle >=1 && angle <= 100 )
    {
        gotoAndPlay(2);
    }
    else if (angle >=100 && angle < 340) {
        gotoAndPlay(2);
    }
4

1 回答 1

0

您需要将为函数添加事件侦听器的代码放在回调rotate之外的某个位置。rotate事实上,它永远不会被调用。

function rotate(e:Event):void
{
    var position:Number = Math.atan2(mouseY - knob_mc.y,mouseX - knob_mc.x);
    angle=(position/Math.PI) *180;
    knob_mc.rotation = angle;

}
stage.addEventListener(MouseEvent.MOUSE_MOVE,rotate);
于 2015-01-09T18:38:40.947 回答