2011-01-27 8 views
1

ユーザーを次のフレームに導く非常に単純なボタンを作るactionscript 3.0コードは何ですか?私がActionScript 2.0で正しく覚えていれば、 instance_name.onPress = function(){ gotoAndStop(2) } またはそれに類するものです。ただし、これはActionScript 3.0では該当しません。誰かが私に知らせてくれますか?ありがとう!シンプルなボタンを作成するActionScript 3.0コードとは何ですか?

+0

誰でも回答がありますか? –

答えて

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!! 
     } 
関連する問題