Techniques: Flash 5 & Flash MX
written by ilyas usal a.k.a. pom
There are two ways of loading movies with
loading into target
loading into level
Loading into target was explained by Kirupa in
this tutorial, that's why I won't talk at all about it
here. We'll see how to load into target with Flash (5 or MX,
it's the same), and then how to load dynamically with Flash
enough, but you get the idea ]
Use the following links to navigate through this tutorial:
What we need is simple : a button to
launch the load, an empty clip to load the movie in, and a
.swf file (called loaded.swf), in the same folder
as the present movie.
I suppose you know how to create a button. To create
rapidly an empty movie clip, press Ctrl+F8, name it
'container', then click the Scene 1 vignette above
the timeline. Now open the library with Ctrl+L and drag
and drop the movie clip on a new layer of your scene.
u need to give this movie clip the
instance name 'container' (without the '). On your scene,
you should have nothing but a button and an empty movie
clip. The rest is code. Select the button, and open the
Actions Panel. Click the '+', select Basic Actions
and then Load Movie. The scene should look like
[ For the
moment, we're loading into level ]
Select the line that says
loadMovieNum, and enter this : URL : loaded.swf Location : Target container Variables : Don't send
How does this work ?
URL is the movie you want to load. Here, it's loaded.swf.
When you go online, you'll have to put the absolute path
here, or it won't work.
Location : target tells Flash that you're loading into
target. The following field is the target. When you load
into level, you put the level here, here we put the target
movie clip (which is not an expression) container.
The line should read :
loadMovie ("loaded.swf", "container");
Put a button on your
scene, and give it the instance name but in the
Property Panel. Create a new layer in your movie and name
Now add this code to the
first frame of the code layer:
Explanation of the Code:
but.onPress = function
We define the behaviour of the button as a callback function
in the _root. rather than in the button itself here. We
could have done it normally, of course, with a simple on
Instead of creating an empty movie and putting it on the
scene, we do it with Actionscript. Here, we create an empty
movie clip in the _root., named container and located
Exact same line as in Flash 5.
container._x = 150 ;
We set the position of the clip.
As you can see, it's much quicker here, thanks especially to
the new createEmptyMovieClip function. AND the movie clip is
very easy to handle afterwards, as we'll see in the next
This is one of the most awaited new feature of Flash MX. So
far, it was impossible to load dynamically images and sounds
without application such as Generator or Ming. Well, it's
now possible (and easy), which makes Flash a wonderful tool
to build dynamic sites.
First of all, be careful : Flash MX allows you to load
dynamically images that are non-progressive JPEG. Save the
images you want to load under this format, in RVB mode and
everything will be just fine.
picture has been loaded dynamically ]
Actually, it's exactly the same as previously. All you
have to do is replace loaded.swf by any .jpg you want.
As I said, the other advantage of this method is that you
can very easily manipulate what you've just loaded. For
instance, if we want to make draggable the image we loaded,
all we have to do is to write in the first frame of the
dynamically with Flash MX:
It's the same method. The commands
change a bit, but the idea is similar : you create an
instance of a sound object, in which you load the sound.
This instance is what we will use to change the properties
of the sound (volume for instance).
Here again, you can load dynamically sounds under a certain
format, which happens to be MP3.
You create a new Sound object.
You load music.mp3 into mySound. The second parameter is
call isStreaming. If it's set to true, the
sound will play while loading, whereas it will wait until
it's fully loaded before playing if isStreaming is set to
There ! You have just completed this tutorial. I have
provided the source code to the animations so that you can
compare your fla to mine. Click the Download FLA link below
to download the source file: