Posted By

stiobhart on 06/11/09


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]
  3. // rollover action
  4. this.stupidbutton.onRollOver = function()
  5. {
  7. // replace the trace with your required button actions
  8. trace("button rolled over");
  10. };
  11. // end rollover action
  13. // rollout action
  14. this.stupidbutton.onRollOut = function()
  15. {
  17. trace("button rolled off");
  19. }
  20. // end rollout action
  22. // release action
  23. this.stupidbutton.onRelease = function()
  24. {
  26. trace("button pressed");
  28. }
  29. // end release action
  31. // end button actions [rollover, rollout and release]

Report this snippet  

You need to login to post a comment.