Return to Snippet

Revision: 14769
at June 11, 2009 06:52 by stiobhart


Updated Code
// add an event listener to listen for a button release [mouse up] and then
// when it happens - trigger the function called 'buttonstuff'
this.stupidbutton.addEventListener(MouseEvent.MOUSE_UP, buttonstuff);

// buttonstuff function - triggered by the above listener
function buttonstuff(event:MouseEvent):void
{
	
	// replace the trace with your own button actions
	trace("button pressed");
	
}
// end buttonstuff function

Revision: 14768
at June 11, 2009 06:27 by stiobhart


Initial Code
// add an event listener to listen for a button release [mouse up] and then - when it happens - trigger the function called 'buttonstuff'
this.stupidbutton.addEventListener(MouseEvent.MOUSE_UP, buttonstuff);

// buttonstuff function - triggered by the above listener
function buttonstuff(event:MouseEvent):void
{
	
	// replace the trace with your own button actions
	trace("button pressed");
	
}
// end buttonstuff function

Initial URL


Initial Description
actionscript3 version of the basic button action. in actionscript3,  button actions can no longer be attached to the buttons themselves or called from the main timeline.  you need to put an 'addEventListener' in the timeline to 'listen' for interaction with the button and then call an appropriate function to deal with that action.

the button needs to have an instance name.  in this case it is called 'stupidbutton'

Initial Title
actionscript 3  - button action [listen for a single event.  eg. MOUSE_UP]

Initial Tags
actionscript, flash, button

Initial Language
ActionScript