flamingsquirrel

Actionscript 3 Simple click EventListener

If like me you are making the transition from Actionscript 2 to 3 you may well find that creating simple onPress functions don’t use the same syntax. I checked the Adobe help files but got confused by the overly complex details.

If you want a simple clickable moveClip use the following code. The first line means that the movie clip will act like a button and the cursor will change when the mouse is hovering over.

movieclip_name.buttonMode = true;
movieclip_name.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void{
trace(”Yes, this works!”)
}

One Response to “Actionscript 3 Simple click EventListener”

  1. Almog Koren commented on

    I did a post on Tip and Tricks for event listeners this might help everyone
    http://www.almogdesign.net/blog/actionscript-3-event-listeners-tips-tricks/

Leave a Reply