Return to Kroll Design home page

Flash Tutorials (with .FLA files included)

 
« Return

ActionScript 3

Event Listener

An event listener does just that — it listens for events such as mouse clicks, keyboard presses, or whatever type of event is specified. When the event is detected by the event listener, it calls the specified function.

Download the FLA file

Add an event listener to the Start button and the Stop button, such that if the Start button is clicked, the startAnim function will be called, and such that if the Stop button is clicked, the stopAnim function will be called.

start_btn.addEventListener(MouseEvent.CLICK, startAnim);
stop_btn.addEventListener(MouseEvent.CLICK, stopAnim);

ball_animation_mc.stop();

function startAnim(e:MouseEvent):void 
{
	ball_animation_mc.play();
}

function stopAnim(e:MouseEvent):void 
{
	ball_animation_mc.stop();
}


 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM