Categories
Featured jobs
» More ActionScript, Flash and Flex jobs.
» Advertise a job for free
Our network
Advertisement

 »  Home  »  Tutorials  »  Flash  »  Beginner  »  Copying and pasting ActionScript from an animation

Copying and pasting ActionScript from an animation

By Chris Georgenes | Published 09/5/2007 | Beginner | Rating:
Flash CS3 ActionScripted Animation

This tutorial shows you how to capture the animation properties of an object as ActionScript code, and then apply the ActionScript to another object on the Stage.

Requirements

To follow along with this article, you will need the following software and files:

Copying and pasting ActionScript from an animation

1.In Flash, choose File > Open and open the copy_actionscript.fla file. The timeline includes a layer named Ball, which has been animated to bounce up and down (see Figure 1).

2.Move the playhead back and forth to preview the animation.


Figure 1: Move the playhead in the timeline to watch the ball in the Ball layer bounce up and down.

You'll copy and paste this animation to apply it to a completely different object.

3.Click the Insert Layer button below the Timeline to insert a new layer.

4.Double-click the layer name and type Dog.

5.Select the first frame of the Dog layer. Choose the Library panel. Drag the prepared movie clip, mudbubble_dog, to the Stage.

Now you need to give the movie clip an instance name. Instance names are required for applying ActionScript animations.

6.Make sure the Property Inspector is open. If not, choose Window > Properties > Properties. Then choose the Property inspector and type Dog for the Instance Name.

7.Move the playhead to the beginning of the timeline. Select the first frame of the Ball layer, hold down the Shift key, and select the last frame to select all the frames in between.

8.Choose Edit > Timeline > Copy Motion As ActionScript 3.0. This copies the animation to the clipboard, and displays a dialog box prompting you to enter an instance name for the object you will apply this animation to.

9.Type Dog and click OK.

You won't copy the animation directly to the Dog layer. Because the ActionScript refers to the Dog instance name, you can paste the animation into a separate layer, and the animation will still work.

10.Click the Insert Layer Layer button below the Timeline.

11.Select the new layer, and choose Window > Actions to open the Actions panel. You'll paste the ActionScript on the clipboard right into this window.

12.Insert your pointer in the first line, right-click (Windows) or Control-click (Mac OS) to display the context menu, and choose Paste (see Figure 2).

Figure 2: Paste the ActionScript into the Actions panel.

13.Once the code is pasted, close the Actions panel. Now it's time to test your movie.

14.Choose Control > Test Movie to export the test SWF file. The ball and the dog should bounce together (see Figure 3).

Figure 3: The completed movie shows the dog and ball bouncing together.


How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent

Verification:
Enter the security code shown below:
img


Add comment

Spread The Word / Bookmark this content

Clesto Digg it! Reddit Furl del.icio.us Spurl Yahoo!

Comments



Search Entire Site
Add to Google
Advertisements
Article Options
Latest New Articles
Set up a simple IIS Server for Flash
by Peter McBride

Day 1 at FITC Toronto 2008
by Anthony Pace

Simple reflection effect with AS2
by Jean André Mas

ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff

Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F

mailing list
Enter your email address:
mailing list
Subscribe Unsubscribe
© 2000-2007 actionscript.org! All Rights Reserved.
Read our Privacy Statement and Terms of Use...
Our dedicated server is hosted and managed by WebScorpion Webhosting.