Actionscript 3.0 for a button in Flash CS3 and CS4
I have recently been using Adobe Flash CS4 and i must say i am really liking it!! Especially the new tweening and animation, makes life alot easier.
I had to create a button in Actionscript 3.0 today and had some problems getting the button to work.. the actionscript for a button since actionscript 2.0 has changed. For starters you need to give the button an instance name by right clicking the button on the stage and then going to the the properties window you can enter the instance name like in the image below.

button instance for flash CS4
So to create a button in Flash CS3 and CS4 with actionscript 3.0 please follow these steps.
- Create a button, for example create a box using the rectangle tool then right click the box and select covert to symbol then select type as Button, then press OK.

Simple button in flash CS4
- Select the button and then goto the properties window on the right side of the screen. Give the button an instance name of My_Button.

The button instance name
- Create a new layer above your button layer in the timeline called actions. Select the first frame in the actions layer and bring up your actions panel by either going to window -> actions or by pressing F9 on your keyboard.

Create these layers in your timelime

The action panel (F9)
- This is what the action panel looks like
- In the actions panel enter the Actionscript 3.0 below.
[cc lang="actionscript"]
My_Button.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick);
function mouseClick(event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.bluepearl-design.com/"));
}
[/cc]
The Actionscript above will open a new window to www.bluepearl-design.com when clicked, if you prefer the link to open in the same window use this code below:
[cc lang="actionscript"]
My_Button.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick);
function mouseClick(event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.bluepearl-design.com/"), "_self");
}
[/cc]
You can also have the button use a timeline control.
[cc lang="actionscript"]
My_Button.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick);
function mouseClick(event:MouseEvent):void {
gotoAndPlay(2);
}
[/cc]
And that is about it on how to create a simple clickable button in Actionscript 3.0, test the demo out below.
Meta
Categories
- Adobe Flash
- Announcements
- Computers
- Drupal Themes
- phpBB
- Portfolio
- Templates and Themes
- Tutorials
- vBulletin
- BP-Black Series 2 - vBulletin 4 template - Bluepearl Design Templates: http://bit.ly/92SsiQ via @addthis 5 days ago
- BP-Black ver1.33 released, fixes all known bugs. for vB4.0.2 1 week ago
- I favorited a YouTube video -- Everything by Lifehouse http://youtu.be/fjDojEOiMcE?a 1 week ago
- Check this video out -- Everything by Lifehouse http://youtu.be/fjDojEOiMcE 1 week ago
- BP-Light released for vBulletin 4.0.2 http://www.bluepearl-templates.com/products/BP%252dLight-%252d-vBulletin-4-template.html 2 weeks ago
Bluepearl Design
- Premium templates for 3.8.5
- Advertising
- Article: BP-Black Series 2 - Premium vBulletin Template
- BP-Black Series 2 released
- BP-Black Series 2 - Premium vBulletin Template
- input field text colour
- Sub-forums do not display
- report icon moving down
- BP-Grey
- Buy 2 templates get 2 templates free
Archives
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009