Viewers: in countries Watching now:
Taking the principles and skills taught in ActionScript 3.0 in Flash CS3 Professional Essential Training, Adobe Certified Instructor Todd Perkins demonstrates how to put them to practical use in this course. Todd fully explores ActionScript's most powerful features, including creating advanced navigational interfaces and special effects using XML data and adding accessibility to files via closed captioning. Exercise files accompany the tutorials.
In this movie, we'll take a look at how to reuse the Scale class we created in the last movie and apply it to something else. If you're following along, just create a new ActionScript 3.0 document. Let's go to File > Save As and save this file in Chapter_04, reusing_scale, start and call it Reusing.fla, and just click Save. The first thing we'll have to do is define our class path.
If you are following along, and you don't have access to the Exercise Files, we'll be using the same class path that we've been using throughout this chapter. So let's go to Publish Settings, click the Settings tab by ActionScript version, click the Target button to choose a class path, and make sure you choose the right path. Chapter_04, reusing_scale, start, classes. Click Choose and then click OK. Now we have our class path setup. All we have to do is draw something, link it to the ScaleButton class and then make that a button set.
Maybe that sounds a little bit complicated, but actually just use the Oval tool and I am going to draw a green oval with a black stroke. I just create one on the Stage. I'll select that oval and convert it to a movie clip symbol by pressing F8 on my keyboard. I am going to call this Oval, capital O, and actually if you click the Advanced button, you can select Export for ActionScript right there, and change the base class to todd.interactive.ScaleButton.
Make sure all the casing is same as mine. One thing we want to make sure to do if we're going to be scaling something with ActionScript is set the registration to the center. Once you have all that set up, you can click OK. You're actually not limited to using the same movie clip for different instances of the ScaleButton class. So I am going to create a triangle now. I am just going to use the Pen tool, and click few times and create a triangle. Now let's make sure to fill that in.
I'm going to select the triangle, and then convert it to a movie clip by pressing F8 on the keyboard. Follow the same step with registration at the center. The name will be Triangle with capital T. Check Export for ActionScript. Now we'll get the same base class, todd.interactive.ScaleButton. Then click OK, and just for fun we'll make a rectangle too. Draw a rectangle on the Stage with any stroke or any fill, select the rectangle, press F8 to convert it to a movie clip, name it Rectangle, center registration, Export for ActionScript, make the base class todd.interactive.ScaleButton, click OK. That's looking good.
We'll just give these instance names of circle_mc, triangle_mc, and rectangle_mc. And that looks great. Let's create a new layer, name the new layer actions, select the first keyframe of the actions layer, and open up the Actions panel. And now we'll have to import the ButtonSet class, so it's import todd.interactive.ButtonSet.
Create a new instance of the ButtonSet class. I will call mine btnSet, set it equal to a new instance of the ButtonSet class. And then we'll have our ButtonSet instance called btnSet.addButtons. We are on the addButtons method. Inside of the method remember we have to pass an array, so we'll use square brackets and then we'll pass in the three movie clips on stage, the circle_mc, triangle_mc and then rectangle_mc.
Let's go to the next line and put the btnSet on the stage, so type addChild, and we'll add btnSet to the stage. Take a look at your code, test the movie, and rollover the buttons. There we go. You can click the button and it will stay scaled up, show that it's selected, and if you click another button, that button scales back down. So there you have it. You can reuse classes that you create.
There are currently no FAQs about ActionScript 3.0 in Flash CS3 Professional Beyond the Basics.
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.