Using ActionScript to Display Movie Clips
Updated: Aug 30, 2007
Views: 1879
Description: This tutorial will show you how to use movie clips with the Tooltip ActionScript 3.0 component.
To get started, here is all of the code and an example of what we are going to build. More advanced users may only need to look at this example, while others might want to read below where I will go through the code and what each part of it does.
| |
Code used in this tutorial
myTooltip.addOwner(myButton);
myTooltip.content = myMC;
myTooltip.type = "instance";
myTooltip.contentStyle = {autoSize: true, scaleContent: false};
myTooltip.content = myMC;
myTooltip.type = "instance";
myTooltip.contentStyle = {autoSize: true, scaleContent: false};
Part II - Setting Up the File and Adding Tooltip to a Button
The first step is to create a document, button and an instance of the Tooltip and then adding the Tooltip to the rollover states of the button. If you need help doing this, please follow either the AddOwner Tutorial or Show/Hide Tutorial.
Part III - Exporting a Movie Clip for ActionScript
The next step is prepping a movie clip for use with the Tooltip, you will need to have a movie clip in your library to continue. After you have a movie clip in your library, you need to export this movie clip for ActionScript to do this, right click the movie clip in your library panel and select and select linkage. Check the box Export for ActionScript, make sure Export for first frame is checked, and give it a Class name of animatedMC.
Part IV - Use ActionScript to Use the Movie Clip with Tooltip
Add the following code to an actions layer using the actions window (Windows > Actions):
Add an instance of the your animated movie clip:
var myMC:MovieClip = new animatedMC();
this.addChild(myMC);
this.addChild(myMC);
Change the content of the tooltip to be the instance of the movie clip:
myTooltip.content = myMC;
myTooltip.type = "instance";
myTooltip.type = "instance";
Change properties of the tooltip to auto size and not scale the movie clip:
myTooltip.contentStyle = {autoSize: true, scaleContent: false};
If you have any questions please post them on our forum.
Other Tutorials
