Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
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.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101462 Viewers
61 Video lessons · 88220 Viewers
71 Video lessons · 72102 Viewers
56 Video lessons · 103858 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.