Forum Topic: AS: loadMovie()

(3,470 views • 18 replies)

This topic is 1 page long.

<< < > >>
None

SpamBurger

Reply To Post Reply & Quote

Posted at: 12/10/05 08:36 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

AS: Main
What?
In this tutorial you will be learning how to use the loadMovie() command. It is very useful becuase flash only allows 16,000 frames in a file I believe. If you are making a very long movie, and you go pass the frame limit, you can just use the loadMovie() command to add a movie from a URL. It is also useful for if you need a certain file size and you go pass it. Just use the loadMovie() command to add a movie, without barely increasing the filesize. loadMovie() requires exactly three parameters so I will explain them below. Unfortunately, I do not really know about the loadVariablesNum() command, so I will not be teaching that. If anyone wishes to make a tutorial about it, feel free to do so.
------------------
The Code
The loadMovie() command looks like this:
loadMovie(url, target, method);
------------------
The First Parameter
The first parameter is the URL your movie is on. So, replace "url" with this:
http://www.whatever.com/moviename.swf

Flash will then load the contents from that URL.
------------------
The Second Parameter
The second parameter is where you want the movie to be loaded to. You can use _root, _parent, anything you want. (I prefer _root).
------------------
The Third Parameter
The third parameter is the way you want the movie to be loaded. There are two methods: POST, and GET. The POST method will load the movie and NOT show anything extra in the URL. The GET method will load the movie and WILL show extra stuff in the URL. I may be wrong on that, but Im just saying what I know from previous knowledge. If you know the correct thing each method does, please post it here. Also, when you use one of the methods, it must be in quotes. So, POST will be "POST" and GET will be "GET".
------------------
Example Code
Place the following code on the first frame of your movie:

loadMovie("http://www.powercode.riverheart
.net/youare.swf",_root,"POST");

The above code will work. It should load a little animation into your movie.
------------------
I hope you learned something new. If I missed anything, or got something wrong, PLEASE post it here :)

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Rantzien

Reply To Post Reply & Quote

Posted at: 12/10/05 08:40 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,426

You forgot to mention that the method parameter is optional, otherwise it's all good.

Bladderbag
BBS Signature

None

fwe

Reply To Post Reply & Quote

Posted at: 12/10/05 08:42 PM

fwe DARK LEVEL 08

Sign-Up: 07/24/03

Posts: 3,361

Greatest topic ever

wtfbbqhax


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 12/10/05 08:44 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

yes, why dont we all make a tutorial on 1 function, well atleast itll fill up 3 pages of ASmain links

My social worker says im special!

BBS Signature

None

SpamBurger

Reply To Post Reply & Quote

Posted at: 12/10/05 11:38 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 12/10/05 08:44 PM, -dELta- wrote: yes, why dont we all make a tutorial on 1 function, well atleast itll fill up 3 pages of ASmain : links

I thought it was a good idea to make a thread about it. This command is very useful.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

GuyWithHisComp

Reply To Post Reply & Quote

Posted at: 12/13/05 01:49 AM

GuyWithHisComp LIGHT LEVEL 27

Sign-Up: 11/10/05

Posts: 4,010

You can use _root.loadMovie("http://www.whatever.com/m
oviename.swf"); too.
abit shorter :P

BBS Signature

None

Nick

Reply To Post Reply & Quote

Posted at: 12/26/05 02:45 PM

Nick FAB LEVEL 23

Sign-Up: 08/22/05

Posts: 1,977

Would using loadMovie use up bandwidth?

In other news, I used loadMovie to load littleFoot from Adam Phillips' site and the swf was 105 : bytes, just found it funny. What's even more funny is that I loaded supersoldier from Glaiel's site and the swf was 110 bytes ;P


None

Claxor

Reply To Post Reply & Quote

Posted at: 12/26/05 02:48 PM

Claxor DARK LEVEL 10

Sign-Up: 10/21/05

Posts: 2,465

At 12/26/05 02:45 PM, _Nick_ wrote: Would using loadMovie use up bandwidth?

In other news, I used loadMovie to load littleFoot from Adam Phillips' site and the swf was 105 : bytes, just found it funny. What's even more funny is that I loaded supersoldier from Glaiel's site and the swf was 110 bytes ;P

It doesn't actually include the swf in the other swf, it loads it in at runtime, making the filesize small =D

BBS Signature

None

Nick

Reply To Post Reply & Quote

Posted at: 12/26/05 02:56 PM

Nick FAB LEVEL 23

Sign-Up: 08/22/05

Posts: 1,977

At 12/26/05 02:48 PM, Claxor wrote: It doesn't actually include the swf in the other swf, it loads it in at runtime, making the filesize small =D

I knew that, but I just found it funny :D


None

Claxor

Reply To Post Reply & Quote

Posted at: 12/26/05 02:59 PM

Claxor DARK LEVEL 10

Sign-Up: 10/21/05

Posts: 2,465

At 12/26/05 02:56 PM, _Nick_ wrote: I knew that, but I just found it funny :D

Ok, sorry then =D

BBS Signature

None

lkegley9

Reply To Post Reply & Quote

Posted at: 3/8/06 05:10 PM

lkegley9 LIGHT LEVEL 02

Sign-Up: 10/02/03

Posts: 1

You also forgot to mention that the "url" parameter doesn't have to be a URL, but can be a filepath to a file on your computer. And if you are to lazy to find the filepath, just make sure to have the movie in the same folder, and write the file name, with the .swf at the end of course.


None

TrueDarkness

Reply To Post Reply & Quote

Posted at: 3/8/06 05:23 PM

TrueDarkness EVIL LEVEL 27

Sign-Up: 08/31/04

Posts: 4,718

Wow I never learned about this before... extremely awesome. This can be used in a lot of different ways actually. You can use it to reduce file sizes of movies, or link to one of your other movies! Damn that is awesome, thanks Spam!


None

shazwoogle

Reply To Post Reply & Quote

Posted at: 3/8/06 05:27 PM

shazwoogle NEUTRAL LEVEL 11

Sign-Up: 09/27/04

Posts: 2,681


None

TrueDarkness

Reply To Post Reply & Quote

Posted at: 3/8/06 05:28 PM

TrueDarkness EVIL LEVEL 27

Sign-Up: 08/31/04

Posts: 4,718

Question, once it loads the movie is there anyway to tell it to stop, or is the movie loaded and all the flash that you have done is gone... or does it stop loading the movie once the animation is done?


None

Majestic-Boy

Reply To Post Reply & Quote

Posted at: 9/19/06 11:42 PM

Majestic-Boy FAB LEVEL 19

Sign-Up: 06/27/06

Posts: 529

Could you give a more concrete example? I want to use this function very badly because my flash is so large that when the user visits my site, it takes 1 minute for the LOADING to load. *ouch

Or a .FLA file would be better.

Sorry, i'm not being demanding or anything but I don't exactly understand your explaination. ;-) I only understand a little. =)

Thanks very much! ;-)

Majestic-Boy's Awesome Ways to Make Money and PHP Tutorials.


None

SuperSpark

Reply To Post Reply & Quote

Posted at: 6/20/09 01:58 PM

SuperSpark NEUTRAL LEVEL 06

Sign-Up: 04/02/09

Posts: 48

I tried this, but I have a problem. The Movie I'm trying to import is on my computer, not on the internet, so it's not really working for me. I tried to make the URL in the code become the address of the file inside my hard drive, but no cigar...


None

SuperSpark

Reply To Post Reply & Quote

Posted at: 6/20/09 02:48 PM

SuperSpark NEUTRAL LEVEL 06

Sign-Up: 04/02/09

Posts: 48

bump


None

asgrunt

Reply To Post Reply & Quote

Posted at: 6/20/09 05:00 PM

asgrunt NEUTRAL LEVEL 01

Sign-Up: 05/26/09

Posts: 164

that is only the global function loadMovie(). There exists also a mc method: mc.loadMovie(file, optional:method). This comes in very handy if you do a modular site. This mehod is preferred to the global function since you never can forget to give a target for loading (its the instance you invoke the method at).

You can load swf as well as bitmap files (gif, jpg, png)

If you load something this way the content of the time line you load into will be completely replaced by the loaded file. So if you load into _root, everything will be deleted. Therefore its better to create an empty mc as a holder for the files.

example (frame script at _root in a file named index.swf):

var mContent:MovieClip;

function initSite(){
mContent = this.createEmptyMovieClip("holderContent ",this.getNextHighestDepth());
mContent.loadMovie("home.swf");
}

Be aware that _root in home.swf no longer adress its own _root but that of index.swf which makes totally sense since after loading home is identical with the mc referenced in mContent.

You can either use _lockroot = true (in home) so that _root still does adress its own main time line. Or store a ref to that time line in a var: var mRoot:MovieClip = this. If you want to invoke functions in index from home, use _root.functionName or relative pathing (this._parent.functionName). From index, everyhing in home can be called with mContent.instanceName.


None

asgrunt

Reply To Post Reply & Quote

Posted at: 6/20/09 05:14 PM

asgrunt NEUTRAL LEVEL 01

Sign-Up: 05/26/09

Posts: 164

sorry, forgot: to get rid of the loaded files: mContent.unloadMovie().

the main reason why you should use mc.loadMovie (or the global function) is not the max number of frames (isn't 16.000 enough?). There are several other advantages:

- you can build a modular site consisting of several swf with the content, i.e. index.swf (loads everything needed into container mc), intro.swf, home.swf, products.swf, service.swf, contact.swf, impressum.swf and so on. The user needs only to download exactly the files he wants to look at. If he is oly interested into your products, he doesn't need to download your service.swf etc. Makes sites faster to download

- if you want to change something no need to go through your whole app. Just look a the one swf that has the exact content and change only that without running danger to mess up the whole site

- you can build galleries where your customer could change the pisct without ever opening flash

- you can build anims for games and change its graphics on the fly by importing dynamically files


All times are Eastern Standard Time (GMT -5) | Current Time: 08:25 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!