You want to make a button in flash using AS3? It’s easy!
1)MAKE SURE you’re movie clip has an instance name!

Also, please please please make sure you’re dealing with an actual “movie clip” and not a “button”.
The next step is to go to the Actionscript layer (you should have a layer label “actionscipt”, “as”, or something of that nature to hold all of your actionscript) and insert the following code:
instanceNameOfMovie_mc.addEventListener(MouseEvent.CLICK, nameOfFunction);
function nameOfFunction onClick(event:MouseEvent):void
{
trace(“You just made an event handler to handle mouse click events!”);
}
And you’re done! You’ve made a movieclip that acts like a button with event handlers!
Now, some of you may ask, “Why not just use a button?”. The reason, the gives you more flexibility, and this is your first step in learning how to control event handlers. There may be times when using a button may be more appropriate, but for now, this is the way to go.
You can see a list of what other “Events” can be paired with the “MouseEvent” listener here. Experiment!
Post comment
Recent Posts
- Ross Experiential Marketing
- Frum Tha Ground Up
- River Place Plantation
- Introductory/Explanation Animation for Shipme.me
- Carolina Casualty Animation
Recent Comments
- admin on Inspiration #1: Web Design: CSS
- Jeff on Inspiration #1: Web Design: CSS
- Printable Coupons For Great Clips Haircut on New Marvel Vs. Capcom 3 Wallpapers for iPhone, iPad, Desktop, and Android
- Christmas Solar Lights Outdoor on New Marvel Vs. Capcom 3 Wallpapers for iPhone, iPad, Desktop, and Android
- Printable Coupons on New Marvel Vs. Capcom 3 Wallpapers for iPhone, iPad, Desktop, and Android
Archives
- April 2012
- February 2012
- January 2011
- December 2010
- November 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
Categories
- Facebook Designs
- Flash Animation
- Flash Lessons
- Gaming
- Gaming Wallpapers
- Inspiration
- Random Fun
- Ryan's Social Media
- Ryan's Web Site Design & Development
- Ryan's Work
- social media
- Videos
- Web Design