Posted By

stiobhart on 06/11/09


Tagged

actionscript flash button college


Versions (?)

actionscript - button action [to attach to the timeline]


 / Published in: ActionScript
 

basic actionscript button action that should be attached directly to a frame on the timeline - NOT to the button itself. this is a slightly more complex version of the 'standard' button action which attaches directly to the button itself. this version has the advantage of allowing you to keep all your actionscript code together in one place on the timeline, rather than having it scattered across all the various elements in your movie.

for this to work, your button must have an instance name. in the code here, my button instance name is "stupidbutton".

this action will NOT work in actionscript 3, which uses "addEventListener" to respond to button events.

make sure you're attaching this action to the timeline and not directly to the button. the actions window should say "actions - frame" when you open it. if it says "actions - button" you're trying to attach this action to the button itself and flash will blow a fuse!

  1. // begin button actions [rollover, rollout and release]
  2.  
  3. // rollover action
  4. this.stupidbutton.onRollOver = function()
  5. {
  6.  
  7. // replace the trace with your required button actions
  8. trace("button rolled over");
  9.  
  10. };
  11. // end rollover action
  12.  
  13. // rollout action
  14. this.stupidbutton.onRollOut = function()
  15. {
  16.  
  17. trace("button rolled off");
  18.  
  19. }
  20. // end rollout action
  21.  
  22. // release action
  23. this.stupidbutton.onRelease = function()
  24. {
  25.  
  26. trace("button pressed");
  27.  
  28. }
  29. // end release action
  30.  
  31. // end button actions [rollover, rollout and release]

Report this snippet  

You need to login to post a comment.