logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Full Schedule
g
g Flash and Animation Site

BellaOnline's Flash and Animation Editor

g

Program Button with ActionScript and Script Assist


We have completed our FlashR CS4 eCard animation, added the stop() code and built the button that our viewer will use to replay the animation a second or subsequent time. Now we are ready to attach some ActionScript 3 code to our button. This code will tell Flash to listen for a mouse event, such as our button being clicked. Then we will write a function to tell Flash what to do when the button is clicked. Our function will tell Flash to go back to the first frame and play the animation again.

Open your working file into Flash CS4.

1. First we need to add our Replay button onto the stage. We do not want the button to be available until the animation plays through the first time and stops. So, let's add the button to the last frame of the animation (Frame 75). Also to prevent the button from showing on the stage until Frame 75, we need to add a Keyframe. Right-click on Frame 75 of the Button layer and add a Keyframe. Flash will give you 74 blank frames and a keyframe on Frame 75.

Now, drag an instance (copy) of the Replay button from the Library onto the snow at the bottom right corner of the stage.

2. In order to control this instance (copy) of the Replay button with ActionScript, we need to give it a unique name. With the button selected, go to the Properties panel and replace "Instance Name" with "replay_btn". Now we can start working on the ActionScript.

3. Click on Frame 75 of the Actions layer and open the Actions panel. Here is our code so far.

import flash.display.MovieClip;
this.stop();

4. Let's tell Flash to listen for a mouse click on our replay_btn button. We will use Script Assist again to write our ActionScript. Click on the Script Assist button to open the top pane.

Click on the Plus sign to open the list of ActionScript codes. From this code list, click flash.events IeventDispatcher Methods addEventListener. Flash will automatically update our code by adding these two lines.

Next →

Join us in the Flash forum.




Add Program+Button+with+ActionScript+and+Script+Assist to Twitter Add Program+Button+with+ActionScript+and+Script+Assist to Facebook Add Program+Button+with+ActionScript+and+Script+Assist to MySpace Add Program+Button+with+ActionScript+and+Script+Assist to Del.icio.us Digg Program+Button+with+ActionScript+and+Script+Assist Add Program+Button+with+ActionScript+and+Script+Assist to Yahoo My Web Add Program+Button+with+ActionScript+and+Script+Assist to Google Bookmarks Add Program+Button+with+ActionScript+and+Script+Assist to Stumbleupon Add Program+Button+with+ActionScript+and+Script+Assist to Reddit



 



RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the Flash and Animation Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.

g


g features
Motion Workspace - Checkbox, Dials and More

Motion Workspace - Menu, Icons and Sliders

The Motion Toolbar Tools

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor