Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In Flash CS4 you can copy motion tween data as ActionScript 3.0 code. The reason why that is useful is because it allows you to apply animations to multiple objects while the Flash movie is playing. In this movie we'll take a look at how to do that and before we start I just want you to be aware that this is really going to be of most use to people who already know and work with ActionScript code. If you are following along go ahead and open up ActionScript_Animation.fla in the Chapter 01 folder. If you don't have the exercise files just create a motion tween on the Stage. So what I am going to do is right-click or Ctrl-click my motion tween and then I'll choose Copy Motion As ActionScript 3.0. Now the ActionScript 3.0 code is in the pasteboard so what I am going to do is create a new layer, I am going to name the new layer actions, I am going to select the first frame of the actions layer and open up the Actions panel by choosing Window > Actions.
In the Actions panel I am going to press Command+V on the Mac or Ctrl+V on the PC to paste the code that Flash copied for me. You'll notice that when you paste the code in Actions panel there is a lot of code. This code contains all the information about your animation. If you want to apply this animation to another object you need to uncomment the code, which in my code is on lines 38. It's the one that has the word addTarget in it. Now before we do that I am going to create another instance on the Stage so I am going to close the Actions panel, I'll delete the animation layer and I'll create a new layer and in the new layer I am going to drag an instance of the monster on to the Stage.
Now what I am going to need to do is giving instance name to the monster so this is going to be a movie clip. So I'll select the monster, go to Properties inspector and give it in an instance name by clicking on the Instance Name field and I'll called this, monster, all lower case. Now I'll go back to the Actions panel. I'll select the first keyframe of the actions layer and then press Options+F9 on the Mac or F9 on the PC to open the Actions panel. Now I am going to go to line 38 in my code. Remember it's the one which says addTarget and then I am going to delete the two forward slashes at the beginning of the code.
Forward slashes in ActionScript indicate a comment or it disables a line of code from being run in the Flash Player. So by deleting the forward slashes we are causing this block of code to run. The area that we're really concerned with is the brackets and instance name goes here so I am going to select all of that, I am going to delete it and I am going to replace that with the instance name of the monster on the Stage which is just monster. Then from there we have a number, which is 0 right now, which identifies how many times the animations will play. So I'm going to leave that at 0 for now and I am going to test the animation in the Flash Player. And there is the bouncing monster.
Now the great thing about this feature is that you can apply this to as many audits as you want when you create them using ActionScript. So all you have you do to copy an animation and apply with ActionScript is right-click or Ctrl-click the animation in the timeline, choose to copy the motion as ActionScript 3.0 and uncomment the addTarget line and put you instance name in the parenthesis.
Get unlimited access to all courses for just $25/month.Become a member
107 Video lessons · 34016 Viewers
94 Video lessons · 23758 Viewers
100 Video lessons · 4214 Viewers
83 Video lessons · 9273 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.