|

Flash
Levels
A
single timeline can often limit the capabilities of a designer,
as Flash movies often grow larger than the single timeline in which
it is created. The movie symbol often succeeds at allowing the developer
to utilize independent elements, but sometimes even these symbols
become limiting.
A
way to solve this problem is build into Flash: Flash has the capability
to load additional movies into a main movie by using ActionScript.
The
ActionScript command for loading a movie is:
LoadMovieNum("yourMovie.swf", Level);
The
file "yourMovie.swf" is obviously replaced by the name
of your valid SWF file, but the Level field is completed by adding
a number (a level) to this field.
Let's
take a second to talk about this Level for a bit. Think of Level
numbers a little like the layers on your timeline. Objects located
at the top of the timeline appear "above" objects located
at the bottom. This Level attribute determines the location of the
loaded movie: the higher the number, the further "above"
the other levels objects appear.

Your
main movie level is considered to be Level 0 (_level0).
Level 0 defines the stage size, the frame rate and background color
for all the levels loaded above it. The levels loaded above Level
0 are transparent: background colors do not apply. However,
all buttons and symbols are active on all layers. A button on Level
0 can interact with a movie on Level 1 and so on.
When
you wish to load a movie, you use the LoadMovieNum
ActionScript command and set the parameters accordingly. So, if
I have my movie root with background imaging on Level 0, lets assume
I have an audio SWF and an interactive menu SWF I want to load.
I would use the following commands:
LoadMovieNum("audio.swf",
1);
LoadMovieNum("menu.swf", 2);
From
a user perspective, they are seeing one movie, but you have segmented
it into more manageable pieces.
If
you wanted to use the buttons in the menu.swf file (on Level 2)
to alter the timeline of the movie on Level 0, you can simply call
the level and frame name or number like this:
on (release){
_level0.gotoAndPlay("intro");
}
This
tells Flash that when the user releases the mouse button, play the
frame named "intro" on Level 0. Named movie symbols, named
text fields (Flash MX), frames and scenes can all be given instructions
from different levels. How cool is that!
Why
would you want to do this?
You
could be saying to yourself, "Yeah, that's cool. I can load
Flash movies into Flash movies. Well, so what? What is it good for?"
Wow.
Glad you asked.
We
are going to use a real world example to illustrate the power of
this tool. Recently, wecreated a multimedia presentation for a client
that was to stream off a CD. They are incorporating video clips,
voice over audio, soundtrack audio and tons of high quality graphics.
The Flash FLA file was 313MB, and when Flash finally created the
self contained .exe file, the compiled version was about 200MB.
This size file stores well on a CD, but does not stream easy as
one complete unit. The viewer of this program would have to wait
in upwards of six minutes for the disk to auto run and play after
the CD was inserted. Not a realistic solution.
So,
what we did is we broke this project into about six reusable parts
and eighteen miscellaneous SWF files. The Level 0 file, which is
the background images, mini "Welcome Video" and welcome
animation starts the program. This file is 800kb, spins up fine
and is used as the EXE to start the AutoRun. This movie stops and
then loads a Level 1 Audio track, a Level 2 Menu Button Tree, and
a Level 3 Text layer. Each of these files is about 25kb.
Then,
after the user clicks "Start the Presentation", the Level
3 Text layer is replaced by the first movie segment. The current
level unloads, and the new video SWF starts to load. The
video segment, at about 10MB in size, comes in quickly (about 3
seconds to load off CD with 40X speed CD Drive) and starts playing.
When this ends, it is replaced by a new animation SWF. The video
SWF unloads and the new animation SWF (about 3.5MB) loads.
This takes about 1 second to come in.
As
we move through the program, the same layer is loading and unloading
different SWF elements. Notice that the Level 1 Audio track still
plays its merry loop and the Level 2 Menu Buttons still controls
the entire movie, but they don't load with each new element. All
the background images on Level 0 stay intact as well. They don't
need to continually reload with each new element, dramatically shaving
load times and file sizes.
On
this project, we broke the program into bits of no more than 10MB
and the user experiences little or no lag using an average CD Drive.
Now, instead of a huge long wait, the viewing audience gets the
program delivered in chunks, as they need it.
This
example could translate to a web project you are working on. If
you have a huge site or presentation you wish to display using Flash,
using the LoadMovieNum
command allows your user to control download times by only receiving
the files they want. A complete site download may take 5 minutes
at a slow connection, but if you create the site using several different
movie elements, your user may have the main portal loaded in 15
seconds. Then, if they click on the About You link, only that movie
loads. Again, by loading in chunks, you shave load times way down.
LoadMovieNum
is a powerful tool for the intermediate and advanced ActionScript
programmer. Experiment with it and let us know how you do! Have
fun!
Contact
Us:
949-633-7915
DevGroup@tothweb.com
|