Jump to content

Event


Twango

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...