2011-01-27 57 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!! 
     } 
相关问题