A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11211 Flash Movies | 9 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Zeeshan Ozair
» Title: Lensflare
» Description: Probably one of the better lens flare effects available out there.
» More by Zeeshan Ozair


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6567 Flash Sites | 4 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: ANDY FOULDS DESIGNi
» Comments: The Award-winning Flash Design Portfolio of Freelance Web Designer Andy Foulds


Random Links | Add your own Flash Related Links
Flash Tutorials 1170 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create Graduation Photo Slideshow to Cherish School Memories
» Making movieclips point at the mouse
» Create Flash slideshow for Youtube
» Move a sprite with the keyboard
» Convert FLV to AVI video with DIVX codec to author a desired video with your favorite FLV movie!
» Flash Video Conversion Guide for Apple TV
» How to Convert FLV to iPhone movies
» Convert FLV(Flash Video) video to Cell Phone
» Convert FLV to AVI with XviD video codec to enjoy a DVD quality video with half of its size
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Visual / UI Designer
Aquent
US-CA-San Francisco

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Tips_And_Techniques

Categories Explained simple: Loading external .swf's in the right position
Author: Mindaugas

 
Page 1
1

We're gonna do it simple - no fancy stuff, just basics explained. So, if you need that a flash movie loads another flash movie in the right position - that's covered here.

Where did I needed? I'm designing a 100%-flash site with various types of information. One of the subsections had a few pages of text and some 14 pictures. Now we have a dillema here: if we combine everything under one umbrella, i.e. text and pictures in one swf movie, it's gonna be large (perhaps app. 1MB) - webpage will be laoding slowly. But that's a simple sollution, no headache. A more difficult one: separate the text and pictures into different movies - loading time decreased, since the text loads first (quickly) and a user has an option to check pictures (need to load another swf with pictures after clicking on "pictures" button). The main thing is that an impression of decreased loading time and option to choose is created. But that's a bit more sophisticated. It's done by laoding the swf movie with pictures into the text swf. How to do it right? Step by step answer bellow.

TOOLS USED

loadMovie();
unloadMovie();

- empty movie clip.
- "parent" swf.
- "child" swf.

WHAT DO THEY DO?

loadMovie() - Actionscript command, which loads the movie. Simple. The parameters in the brackets are used to tell 1) which movie to load and 2) where to load it.

unloadMovie() - Actionscrip command, which unloads the movie from cache. Typically, I don't use this command - once user has loaded the movie, it stays in the memory, so if he comes back - the movie will already be in the memory and could be immediatelly played (short - saves time). This command unloads the movie from the cache. You might need to use this command if your "child" movie overlaps with something in your "parent" movie.

empty movie clip - used to define location in the "parent" swf, where the "child" swf is loaded. Does not contain any information in it - it's blank. IMPORTANT - you have to add any instance name (in Flash MX in "Properties" - just type in), which will serve as a link defining location.

- "parent" swf. The movie you're working in, the movie into which you want to load the "child". (Text in my case)

- "child swf. The movie containing information, which you want to load into the "parent" swf. (Pictures in my case)

BACKGROUND TECH INFO

We will use the loadMovie() command to load the child into the parent. However, in flash this command ALWAYS loads the movie in the top left corner (0;0) of an object. If you're working in the Scene1 - that will look ugly, since all your text in "parent" will appear underneath the "child". The trick here is to use the empty movie clip, which calls this command - the movie will be loaded in the top left corner of the movie clip, i.e. in the position, where you have placed that empty movie clip. So, to define the position where the child should load, place the empty movie clip in the desired position in the parent swf. Simple.

HOW-TO STEP BY STEP:

1. Create your child swf, including all external info that you want to load into the parent. For simplicity, let's name it "child.swf".

2. Create your parent swf, including all necessary info. Again, let's name it "parent.swf".

{There are numerous ways to solve this problem. I'm gonna present mine - I just find it more flexible and understanable).

{ALL steps bellow are done in the "parent.fla", except mentioned otherwise.)

3. In the parent movie, create an emtpy movie clip (Ctrl-F8), let's name it "loader". Go back to "Scene 1".

4. On the timeline, insert new layer, let's name it "loading layer". That's the layer, in which the "child" will be loaded. So, check what you need to be visible from "parent", and put that layer in the appropriate position.

5. I use button, which triggers the movie to be loaded. So, insert that button with any text you need in the layer and the place you need it.

6. Click on the button and open "Actions" (F9). Insert the following script:

on (release) {
 gotoAndPlay ("loading child");
}

This script will take you the labeled keyframe "loading child", where the emtpy movie clip is placed and where loading takes place.

7. On the "loading layer" insert a keyframe (F6) at the place, where you want the loading actions to take place. I typically do it at the very end of the "parent" swf, i.e. it would be the last keyframe.

8. Click once on that keyframe on the timeline. In the "Properties" label it "loading child", i.e. just type in those words, where it says "frame label" (bottom left).

9. Insert the emtpy movie clip in that keyframe (just drag from the library). Place it at the position on the screen where you want the "child" to load.

10. Select the movie clip (the one on the screen). In the "Properties", type in the instance name (on the bottom left). Let's say "loading_position".

11. Select the keyframe you're working in (the one labeled "loading child". Open "Actions" (F9). Insert the following script for this frame:

loadMovie("child.swf", "load_position");
stop();

The first line loads the movie "child.swf" where the empty movie clip is placed (remember: it's instance name is "load_position"!). The second line stops the "parent" movie on that location - I use it to control the movie flow. Basically, you need it in order to see the "child" movie.

12. That's it. While working in the "parent" movie, test it (Ctrl-Enter) - should be fine.

You may also want to unload the "child" movie after viewing it if it's blocking what you see in the "parent". Simply use the unloadMovie() command in the parent.

Hope you find it useful. And I do hope I made easy to grasp. Shame on me if not - took more than an hour to type that all.

1

» Level Intermediate

Added: : 2003-09-21
Rating: 7.00 Votes: 83
Hits: 4082
» Author
ehm... still doing my first steps in flash. but already figured out a few bits.
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers