2015-01-09 49 views
0

如果有人幫助我完成某些編碼,我會加以考慮。旋轉動畫片段並更改爲特定幀(S.O.S)

我有這個代碼,我以前得到用鼠標旋轉一個movieclip,並得到另一個框架,大學的工作(我們只做了補間,剛剛學會了基本編碼),但我不能得到任何結果。

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

你需要把該添加事件偵聽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); 
+0

我做了你告訴我的,但這只是使動畫片隨鼠標移動。我覺得我誤導了你,當我按下並移動鼠標時,knob_mc會旋轉,但是我不能讓AS3腳本在If中跳到另一個幀的角度,你有什麼要求嗎? – 2015-01-09 18:58:23

+0

它是這樣的[鏈接](http://www.fastswf.com/OFR3Q0E) – 2015-01-09 19:10:25

+0

[鏈接](http://www.fastswf.com/AMrZieU)這是預期的,但與下一幀步驟) – 2015-01-09 19:24:44