Learning ActionScript 2.0 in Adobe Flash |
|
|
|
| Working with Text and Strings > Using HTML-formatted text > About embedding images, SWF files, and movie clips in text fields > Controlling embedded media with ActionScript | |||
Flash creates a new movie clip for each <img> tag and embeds that movie clip within the TextField object. The <img> tag's id attribute lets you assign an instance name to the movie clip that is created. This lets you control that movie clip with ActionScript.
The movie clip that Flash creates is added as a child movie clip to the text field that contains the image.
For example, the following example embeds a SWF file in a text field.
To embed a SWF file in a text field:The SWF file is created in the same directory as the FLA. For this exercise to work correctly, you need the SWF file to generate so that you can load it into a separate FLA file.
Save the file in the same folder as the animation.fla file you created previously.
this.createTextField("textField_txt", 10, 0, 0, 300, 200);
textField_txt.html = true;
textField_txt.htmlText = "Here's an interesting animation: <img src='animation.swf' id='animation_mc'>";
In this case, the fully qualified path to the newly created movie clip is textField_txt.animation_mc.
To control the SWF file as it plays in a text field, complete the next exercise.
To control a SWF file that plays in a text field:
stop_btn.onRelease = function() {
textField_txt.animation_mc.stop();
};
Now, whenever you click the stop_btn button instance, the timeline of the animation nested within the text field stops.
For information on making your embedded media into a hyperlink, see About making hypertext links out of embedded media.
|
|
|
|