Program Button with ActionScript and Script Assist
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.
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.
Copyright 2018 Adobe Systems Incorporated. All rights reserved. Adobe product screen shot(s) reprinted with permission from Adobe Systems Incorporated. Adobe, Photoshop, Photoshop Album, Photoshop Elements, Illustrator, InDesign, GoLive, Acrobat, Cue, Premiere Pro, Premiere Elements, Bridge, After Effects, InCopy, Dreamweaver, Flash, ActionScript, Fireworks, Contribute, Captivate, Flash Catalyst and Flash Paper is/are either [a] registered trademark[s] or a trademark[s] of Adobe Systems Incorporated in the United States and/or other countries.
Editor's Picks Articles
Top Ten Articles
Content copyright © 2019 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.