Jump to content

Event


Twango
 Share

Recommended Posts

Hi, I use As3/CS5,I (generally) use:MovieClip.addEventListener(MouseEvent.CLICK, declareFunc);function declareFunc(M:MouseEvent):void{stop();}but i want to just do MovieClip.addEventListener(MouseEvent.CLICK, gotoAndStop(2));or somthing, but this gets an error, how can i fix this?Thanks :)

Link to comment
Share on other sites

Hi, I use As3/CS5,I (generally) use:MovieClip.addEventListener(MouseEvent.CLICK, declareFunc);function declareFunc(M:MouseEvent):void{stop();}but i want to just do MovieClip.addEventListener(MouseEvent.CLICK, gotoAndStop(2));or somthing, but this gets an error, how can i fix this?Thanks :)
When adding an event listener, you can only send a reference to a function. If you use parenthesis you're running the function right there and sending the return value as the event handler. Since the return value of gotoAndStop() is not a function, it throws an error.Something like this should work:
MovieClip.addEventListener(MouseEvent.CLICK, declareFunc);function declareFunc(M:MouseEvent):void{gotoAndStop(2);}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...