590
Chapter 7: ActionScript for Flash
Description
Method; loads SWF or JPEG files into a movie clip in Flash Player while the original SWF file
is playing.
Tip:
If you want to monitor the progress of the download, use
MovieClipLoader.loadClip()
instead of
this function.
Without the
loadMovie()
method, Flash Player displays a single SWF file and then closes. The
loadMovie()
method lets you display several SWF files at once and switch between SWF files
without loading another HTML document.
A SWF file or image loaded into a movie clip inherits the position, rotation, and scale properties
of the movie clip. You can use the target path of the movie clip to target the loaded SWF file.
When calling
loadMovie()
, set the
MovieClip._lockroot
property to
true
in the loader
movie, as shown in the following code. If you don’t set
_lockroot
to
true
in the loader movie,
the loader has access only to its own library, but not the library in the loaded movie:
myMovieClip._lockroot = true;
Use the
MovieClip.unloadMovie()
method to remove SWF files or images loaded with the
loadMovie()
method. Use the
MovieClip.loadVariables()
method to keep the active SWF
file, and update the variables of the SWF file with new values.
Using event handlers with
MovieClip.loadMovie()
can be unpredictable. If you attach an event
handler to a button using
on()
or if you create a dynamic handler using an event handler method
such as
MovieClip.onPress
, and then you call
loadMovie()
, the event handler does not remain
after the new content is loaded. However, if you attach an event handler to a movie clip using
onClipEvent()
or
on()
, and then call
loadMovie()
on that movie clip, the event handler
remains after the new content is loaded.
You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Example
As shown in the following example, you can use
loadMovie()
to load the image picture.jpg into
a movie clip and use the
MovieClip.onPress()
method to make the image act like a button.
Loading a JPEG using
loadMovie()
replaces the movie clip with the image but doesn’t give you
access to movie clip methods. To get access to movie clip methods, you must create an empty
parent movie clip and a container child movie clip. Load the image into the container and place
the event handler on the parent movie clip.
// Creates a parent movie clip to hold the container
this.createEmptyMovieClip("logo_mc", this.getNextHighestDepth());
// creates a child movie clip inside of "mc_1"
// this is the movie clip the image will replace
logo_mc.createEmptyMovieClip("container_mc",0);
logo_mc.container_mc.loadMovie("http://www.macromedia.com/images/shared/
product_boxes/80x92/studio_flashpro.jpg");
// put event handler on the parent movie clip mc_1
logo_mc.onPress = function() {
trace("It works");
};
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...