What is the actionscript 3.0 code to make a very simple button that brings the user to the next frame? If I remember correctly in ActionScript 2.0 it was: instance_name.onPress = function(){ gotoAndStop(2) } Or something like that. However, this isn't the case for ActionScript 3.0. So could someone please let me know? Thanks!
1
votes
4 Answers
3
votes
ActionScript 3 uses an event based system, so to be notified when the user clicks a DisplayObject, you need to listen for the click MouseEvent.
myDisplayObject.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
event.target.gotoAndStop(2);
}
1
votes
the answers here have the corret function for the functionality, but have a consideration user experience too, you might want to assign these values:
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
votes