EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 107

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 youre 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" />
NOTE
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.

Table of Contents

Related product manuals