Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Loading Movies Technique In Flash
lairz
post Apr 6 2006, 06:11 PM
Post #1


Member [Level 1]
****

Group: Members
Posts: 71
Joined: 6-April 06
Member No.: 21,410



What is loading movies technique? Well for example if you are buildin a 7 section website fully flash animated, the whole site is flash, one option is to make the 7 sections in the same movie, but the result will be a huge movie, that will take a lot of time to load, and probably the user wont stay that long to wait. The other option is to make one main movie and 7 other movies one for every section and then load does movies dinamically into the main movie, in that case the user its gonna load the main movie and then just load the section hes gonna navigate.
Now lets get down to business .

Asumming you have your main movie and you have your menu buttons. you have to attach this script in to the button

CODE
on(press){
unloadMovieNum(10);
}
on(release){
loadMovieNum("sectionname.swf",10);
}

Now let me explain you the code.

The on statement its pretty simple it means the state of the button,on(press) means that when you press the button in the movie, the code between the cuirls its gonna be executed, the same with the on(release) the code will be executed when you realesed the button.

First lets talk about the "loadMovieNum" code, this code load the movie ("whatever.swf") into the main movie.
we need to tell the code 2 things first the name of the movie we are about to load :
loadMovieNum("whatever.swf",);
secondly we need to tell the code in wich level we want the movie to be loaded:
loadMovieNum("whatever.swf",10); // This means that the movie called whatever.swf will be loaded in level 10.

Now let me explain to you the level thing:
the main movie is level 0 by default, you can think of level as leyers, something in level 10 will be on top of level 0, for a example if your movie is 300x300 size (level0), and then you load a movie with a 300X300 filled square on level 5 you wont see a thing cause level 5 is on top on level 0 and since you have a square filling the hole movie it wont let us see anything that is the lower levels. (you can use whatever level you want i choose 10 for no reason) also you can load things on different levels an the same time, for example i can load a logo animation on level 50 and then load other things in the lower level in that case the logo will be always on top, no matter what.

Now let me explain the unloadMovieNum code:

its pretty simple it just unload whatever movie is loaded into the level that we specify
for this code we only need to tell one thing and that is the level where the movie we want to unload is.

for example if i want to unload the movie in level 10 i will say

unloadMovieNum(10); and thats it.


Now let take a look again at the code

CODE
on(press){
unloadMovieNum(10);
}
on(release){
loadMovieNum("sectionname.swf",10);
}


This tell me that when i hit the button first it will unload everything that is on level 10 and then load the movie called sectioname.swf into level 10. Remeber that you can change the movie name and the level number.

Why do we need to unload everything in level 10.

For example if we have the section 1 loaded in level 10 and the we load section 2 into the same level without unloading, both sections will be seen at the same time, causing a huge mess, so first you have to unload things.

i hope you like the tutorial, this load thing is one of the huge things in order to build full flash sites.

This post has been edited by electriic ink: Apr 6 2006, 06:37 PM
Go to the top of the page
 
+Quote Post
epox
post Apr 6 2006, 10:22 PM
Post #2


Premium Member
Group Icon

Group: Banned
Posts: 160
Joined: 10-July 05
From: Bogotá, Colombia, South America.
Member No.: 9,238



well as you said, it's very importanat to handle the sections or media with loaders, and if it's not only to reduce the waiting time for a user, it also brings a number of features very useful to mantain the user informated with all the load status, such as loadprogress, errors, and also, you can interact with the loaded movie before it is displayed, maybe it could be useful to size the movie, add an effect, filter, etc... before it is displayed.

i have a code like this to do all that, i will explain the code below:

CODE

var target:MovieClip = this.createEmptyMovieClip("target", this.getNextHighestDepth());
var clipLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();

listener.onLoadStart = function(target:MovieClip){
    //this fires up when the download begin
    trace("the load has begun!");
}

listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number){
    //do whatever what you want with the progress of the loading information
    trace(target + ".onLoadProgress with " + bytesLoaded + " bytes of " + bytesTotal);
}

listener.onLoadInit = function(target:MovieClip){
    //here you can interact with the loaded clip before it is pisplayed
    target._x = 100;
}

listener.onLoadError = function(target:MovieClip, errorCode:String, httpStatus:Number) {
    //man, sorry but your connection goes down, look for other host company
    trace(target+":"+errorCode+","+httpStatus);
}

listener.onLoadComplete = function(target:MovieClip, httpStatus:Number){
    //touchdown!, at last, now you can fire the animation
    target.start();
}

clipLoader.addListener(listener);
clipLoader.loadClip("here goes your path to your file", target);


well i hope it doesn't look ugly or huge, but it's quite simple.

CODE

var target:MovieClip = this.createEmptyMovieClip("target", this.getNextHighestDepth());
var clipLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();

defines the needed objects:
-target: here is the movieclip where you are going to display your external movie.
-clipLoader: is a nice object that enables to load data in a useful way.
-listener: is the object that listens activity of your clipLoader, and keeps you in touch.

CODE

listener.onLoadStart = function(target:MovieClip)

this function tells you your download has begun, just wait!

CODE

listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number)

this is important, here you will mantain your user with her eyes on the download progress, there are so much ways to display the progress, the prebuilt progress bar of flash, text labels, messages, use whatever what you want, stay fresh.

CODE

listener.onLoadInit = function(target:MovieClip)

your download is done, what i do with it?, here you set propierties, resize, move, add filters, change blend mode, make a transition, or whatever you want

CODE

listener.onLoadError = function(target:MovieClip, errorCode:String, httpStatus:Number)

and what if the information never arrives?, maybe there is an error and here is ower good friend onLoadError, and when it ocurs here you can tell to the fella waiting one hour ago.

CODE

listener.onLoadComplete = function(target:MovieClip, httpStatus:Number)

ready, you are done!

CODE

clipLoader.addListener(listener);

ok you have defined all the events for your listener, so send him to do its work

CODE

clipLoader.loadClip("here goes your path to your file", target);

finally load the clip, it's quite simple, put your file path into the quotes

i hope this can be useful!
Go to the top of the page
 
+Quote Post
lairz
post Apr 7 2006, 05:23 AM
Post #3


Member [Level 1]
****

Group: Members
Posts: 71
Joined: 6-April 06
Member No.: 21,410



Yeah dude thanks for completing the tutorial that was gonna be my next par of the tutorial lol, cause i did the first one oriented to user whos really beggining to learn flash and actionscript.

Thanks

bye dude
Go to the top of the page
 
+Quote Post
ninjamanjaro
post Apr 8 2006, 02:05 AM
Post #4


Newbie
*

Group: Members
Posts: 8
Joined: 8-April 06
Member No.: 21,489



ty guys alot for helping with flash video trick...muhahaha the power the power
Go to the top of the page
 
+Quote Post
Kioku
post Apr 8 2006, 02:04 PM
Post #5


Super Member
*********

Group: Members
Posts: 290
Joined: 17-December 05
From: Error 404
Member No.: 15,848



Formerly, I used to use a simple mathematical trick to get the loading done with the progress, but this appears to be a whole heck of alot simpler. smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Flash Tutorials(7)
  2. Flash Movie Loads...(4)
  3. Loadsound Flash Mx(0)
  4. How To Format Your Flash Disk/ Diskettes(6)
  5. Speed Up Acrobat Reader Loading(21)
  6. Tweening In Flash Mx(10)
  7. Making Interactive Cds With Flash(2)
  8. Using An Actionscript In Flash For Loops(0)
  9. Flashing Your Motherboard's Bios(10)
  10. How To Make 3d Wireframes(2)
  11. 3d Landscape In Swishmax (flash)(1)
  12. Digital Time(2)
  13. Faux Ajax Loading - Css Only(3)
  14. Load A Another Swf Movie Into Flash Player.(0)
  15. Adding Flash Music Player To Home/any Page(4)


 



- Lo-Fi Version Time is now: 23rd November 2008 - 12:43 AM