See how to write and add ActionScript using Code Snippets to bring projects to life with interactivity and programmed animation in Animate CC.
- [Voiceover] Now you can really do a lot with Animate when you start working with ActionScript. This allows you to add interactivity and even some scripted animation and really just gives you unlimited possibilities. And I'm gonna add some ActionScript by adding a new layer and calling it Actions. That's where my ActionScript's gonna be. And it's gonna be right on this frame. And I'll right click and just add a blank keyframe. Because at this point, I want this animation to stop right here and I want to turn this into a button that will jump to a web page.
So that's just some simple ActionScript that I'm going to add and then we'll get into some more complex movement. All right, so, I'm going to select that keyframe, go to window, go down to actions, opening up this actions panel. You can see it right here. It looks really daunting cause it's just white. Well, luckily enough, we have code snippets so I can access code snippets for ActionScript. Twirl this down. I'll dive into, again, actions, timeline navigation, animation, a number of things you can do.
All these different categories. Even if you're creating for mobile as well. But I want to stop the timeline. So I want to control the timeline so I'll go into timeline navigation. I want to stop at this frame. Double click and it will add that code right here. Basically it's this stop word there. And you can see the note and that just happens to be a comment right there. And then I can start to move on because what I want to do now is I want to add functionality for this button right down here. So I'll go into actions right here.
Click to go to a web page. I'll double click. It says hey, you know what, you need to actually select something on the stage. So that's what I'll do. I'll go right down here. Minimize this a little bit. Selecting this logo right here and I'll double click. And it says hey, you know what, you need to give it an instance name. Flash will create an instance name before applying the code sample. So right up here, for this object, you can see that's where I can add the instance name. So I'm actually going to do that just because I want to define the name and I don't want it to be a generic name.
So I'll type in logo there. Double click and it adds this ActionScript. We can see it. Sure enough, right in here. Logo. Listens for a click. Will jump out to whatever page you want it to jump out to. All right, so I'll save this page and I will run it. Check out this SWF. You can see it stops at that point in time. It's not gonna go beyond that point, which is great. Clicking on that movie clip, we can see it's opening up my website.
Pretty straightforward. But you can go beyond that because there's so much that you can do. In fact, when it comes to scripted motion, if you have access to the exercise files, inside of the assets folder, inside of other, there's this RandomAS.txt file. So just open that up in a text editor and essentially, I'm just gonna copy all of this text. So copying that text. Going back in here and at this point, right down here, this is where I want to add that ActionScript.
Pasting that in. And essentially what's happening here, just to show you sort of the power of what you could do is this is gonna create a random ball and it's gonna give it a random color, position it random places and also move it randomly as well. So, command + enter or control + enter. Boom. Bring ideas to life. You can see how that looks. Creating this animation on the timeline would take forever, but with ActionScript you can see, again, how easy it is.
- Setting up projects and changing project types
- Using text and fonts, including web fonts
- Creating graphics
- Importing raster images and vector graphics
- Working with the timeline and keyframes
- Using classic, motion, and shape tweens
- Creating scripted animation
- Publishing to HTML, SWF, SVG, and WebGL