Wednesday, April 02, 2008

Programming buttons in Flash 8

I don't use Flash that often and when I do I always find that programming buttons is a little different each new version of Flash--different enough that I find it really frustrating figuring something out that should be easy. Well, here are the things I learned about making buttons on a recent project.
  • Mouse events, like onPress and onRelease, only work inside buttons, even if the event doesn't involve the button. If you want to script events for key presses, for example, the script has to be on an (invisible) button.
  • Here's the script for a button press :
on(Release){
gotoAndPlay("Scene 2", 1);
}
  • Or if you want the button to open a URL (Take out the blank if you want the same window.):
on(Release){
getURL("http://somewebsite.com", "_blank");
}
  • Here's the script for a key press event:
on (release, keyPress "") {
_root.nextFrame();
this.gotoAndStop();
}

It's not that hard to find these scripts on forums but it seems like it's such a standard thing to use in a Flash animation that it should be easier to find out how to do within the Flash help itself.

No comments :