Viewers: in countries Watching now:
In ActionScript 3.0 in Flash Professional CS5 Essential Training, Todd Perkins shows Flash designers how to incorporate ActionScript code into their projects and create interactive presentations and applications. The course includes a review of ActionScript language basics and the object-oriented programming (OOP) methodology, a tour of those Flash Professional CS5 features designed for developers, such as code hinting and the Code Snippets panel, and instructions on interacting with objects in the Library and placing code on the Timeline. Exercise files are included with the course.
Even when you plan on adding code from the foundation of your application, you may still run into problems because of working with the Timeline. Let's take an example here. Let's say I want to click on the bear in this animation and have it take me to a link to explorecalifornia.org. Now, on the Stage, I have main.mc, and inside of there, there is a bear, and it's called bear_mc. Let's return to the main Timeline, go to the first keyframe of the actions layer and open up the Actions panel.
So I have a link, so when you click on bear_mc, you'll go to explorecalifornia.org. As a side note, if you're curious to learn more about navigateToURL or URLRequest, you can look these things up in Flash Help. So let's see how this code works. I'll test the movie and click the bear over and over again, but I don't get any link. The first thing to do is check to see if I typed the instance name correctly: main_mc.bear_mc, all lowercase.
So on the main Timeline, I have main_mc, and then inside of there, I have bear_mc. However, the bear doesn't walk into the Stage until frame 17. I've also named this bear bear_ mc, but the code does not work. Here is part of the problem. This BearWalking instance is different from what we see on frame 1, which is an instance of a symbol called Bear.
Just because of that discretion, this is not working, even though we have the same instance name. So you can start to see how Timelines can be kind of difficult to work. Here is one solution for that. I'll return to the main Timeline, click on frame 1 of the actions layer, open the Actions panel, select all my code, except for that stop() action - we still want that - and then cut it using Command or Ctrl+X. So I don't want to delete it.
I want to cut it and then paste it somewhere else. Now, I'm going to go to the library, and I'll find the movie clip called BearWalking. I'll have to minimize all my folders. I can find it right here, BearWalking. So I'll double-click the movie clip to enter its Timeline. You can see its animation. I'll add a new layer at the very top, called actions. I'll select the first keyframe of the actions layer, and open up the Actions panel; paste the code.
Now, of course, we don't want to go from main_mc to bear_mc here; we want to apply this code to the WalkingBear. To apply this code to the object that it's already within, I can simply delete everything, except for addEventListener, or I could also type this.addEventListener. This refers to, well, this object, in other words the BearWalking movie clip. So let's test the movie now and see what we get.
So I can click the bear, and the link opens. Now, if I have another animation of the bear, the link won't open; only that BearWalking movie clip will work. So we'd have to copy and paste this code into each of the bear animations to get it to work. I am not going to do that right now, but you can use the same technique in other movie clips: just copy and paste this code into any movie clip, and then when you click on that movie clip, the link will open.
Let's return to the main Timeline. So if you have problems communicating to an object from the main Timeline, remember that you can just cut and paste that code inside of the object itself, so that you can guarantee that the code will work.
Find answers to the most frequently asked questions about ActionScript 3.0 in Flash Professional CS5 Essential Training .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
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.