2011-01-27 55 views
1

什麼是動作3.0代碼,使一個非常簡單的按鈕,使用戶到下一幀?如果我在ActionScript 2.0中沒有記錯,它是: instance_name.onPress = function(){ gotoAndStop(2) } 或類似的東西。但是,ActionScript 3.0並非如此。那麼有人可以讓我知道嗎?謝謝!什麼是製作簡單按鈕的ActionScript 3.0代碼?

+0

任何人都有答案嗎? – 2011-01-27 01:09:10

回答

3

ActionScript 3的使用基於事件系統,所以當用戶點擊一個DisplayObject通知,你要聽的點擊MouseEvent

myDisplayObject.addEventListener(MouseEvent.CLICK, clickHandler); 
function clickHandler(event:MouseEvent):void { 
    event.target.gotoAndStop(2); 
} 
0
function eventResponse(evt:MouseEvent):void {gotoAndStop(2);} 

yourButton.addEventListener(MouseEvent.MOUSE_UP,eventResponse); 
1

的答案在這裏有對功能corret功能,但有一個考慮用戶體驗過,你可能要指定這些值:

myDisplayObject.buttonMode = true //use the "hand" cursor on mouseover 
myDisplayObject.mouseChildren = false //stops the children of the button firing the event, helpful especially when having text lables etc. 
0

私人VAR按鈕:雪碧=新的雪碧( );

 public function ButtonInteractivity() 
     button.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); 
     addChild(button); 
     } 

     private function mouseDownHandler(event:MouseEvent):void { 
     your code!! 
     } 
相關問題