Jump to content
Sign in to follow this  
Twango

Event

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 :)

Share this post


Link to post
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);}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...