我有这个代码,我之前用鼠标旋转一个movieclip,并进入另一个框架,为大学工作(我们只做了补间,只是学习了基本的编码),但我不能得到任何结果。< / p>
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);
}
答案 0 :(得分: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);