About variables
107
The first line of code specifies the image that you want to dynamically load into your
Flash document. Next, you check whether a new value for
imgURL
was specified using
FlashVars or URL-encoded variables. If a new value was specified, the default image URL
is overwritten with the new value. For information on using URL variables, see
“Using
variables from the URL” on page 101
. For information on FlashVars, see
“Using FlashVars
in an application” on page 104
.
The next couple of lines of code define the MovieClip instance, and a Listener object for
the future MovieClipLoader instance. The MovieClipLoader’s Listener object defines two
event handlers,
onLoadInit
and
onLoadError
. The handlers are invoked when the image
successfully loads and initializes on the Stage, or if the image fails to load. Then you create
a MovieClipLoader instance, and use the
addListener()
method to add the previously
defined listener object to the MovieClipLoader. Finally, the image is downloaded and
triggered when you call the
MovieClipLoader.loadClip()
method, which specifies the
image file to load and the target movie clip to load the image into.
3.
Select Control > Test Movie to test the document.
Because you’re testing the Flash document in the authoring tool, no value for
imgUrl
will
be passed by FlashVars or along the URL, and therefore the default image displays.
4.
Save the Flash document and select File > Publish to publish the file as a SWF and HTML
document.
5.
If you test your document in the Flash tool (select Control > Test Movie) or in a local
browser (File > Publish Preview > HTML), you will see that the image centers itself both
vertically and horizontally on the Stage.
6.
Edit the generated HTML document in an editor (such as Dreamweaver or Notepad), and
modify the default HTML to match the following text:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=8,0,0,0" width="550" height="400"
id="urlvariables" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="urlvariables.swf" />
<param name="FlashVars" value="imgURL=http://www.helpexamples.com/flash/
images/image2.jpg">
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
NO
TE
Make sure that Flash and HTML are both selected in the Publish Settings dialog box.
Select File > Publish Settings and then click the Formats tab. Then, select both
options.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...