Jul 20, 2008

Loading Movies Technique In Flash

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Loading Movies Technique In Flash

lairz
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.

 

 

 


Reply

epox
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!

 

 

 


Reply

lairz
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

Reply

ninjamanjaro
ty guys alot for helping with flash video trick...muhahaha the power the power

Reply

Kioku
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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : loading, movies, technique, flash

  1. Adding Flash Music Player To Home/any Page
    How-to (put any song you want!!!) (2)
  2. Load A Another Swf Movie Into Flash Player.
    During Execution. (0)
    Load a another swf movie into Flash player. Create an empty flash document as you like. Save and
    publish it. Create a 2nd flash document as you like. Save and publish it. Note: Both are in same
    directory. Open a first empty flash document. Select the first frame and Press F9. Copy the code
    below and paste it. loadMovie("Your 2nd flash file name .swf", this); Save and run it.....
  3. Faux Ajax Loading - Css Only
    Pretend your site is Ajax based (3)
    Link: http://www.jlhaslip.trap17.com/samples/misc/ajax/index.html Check that out. The first page
    has information and the second and has the actual example of its use with sample CSS code. I find
    that when you visit a site which has a slow server and attempt to view 'large' Image files,
    it is pretty boring to sit and stare at a blank screen, so this little snippet of code can be used
    to give the visitor something to see to indicate that the image is being downloaded. I built a
    small animated gif that sits in the background of the space allocated for the image....
  4. Digital Time
    Create a Digital Time in flash. (2)
    Digital Time 1.Create a Text Field and Create set them instance name = “time”. 2.Select the first
    Frame. 3.Press F9 and Copy Code Below and paste it. CODE _root.onEnterFrame =
    function() {     var time:Date = new Date();     hour =
    (time.getHours()<=12) ? time.getHours() :
    (time.getHours()-12);     hour = (hour<10) ? ["0"+hour]
    : hour;     second = time.getSeconds();     second = (second<10) ?
    ["0"+second] : second;     Minutes....
  5. 3d Landscape In Swishmax (flash)
    some syntax differences but basically same as flash (1)
    OK! this tutorial is inspired by a game at addictinggames.com... im not sure how many of you
    have played it but here it is: God's Playing Field Its a cute little game... but when i first
    played it i though HOW DOES IT DO THAT!!! and by that i mean dot he 3d with the mouse
    and then today i finally got around to making it... I used one of the oldest tricks in the book...
    so lets educate you a lil about flash... Flash does not support 3D directly, you have to find some
    way to make your own. You could develop some complicated system for which you co....
  6. How To Make 3d Wireframes
    A Flash Actionscript tutorial (2)
    Ok to start off this tutorial, i would like to ask you to make a blank flash movie and set the stage
    to have a width of 600 and a height of 400. Now when the movie loads, we need to set some variables
    so lets start off by setting the origin QUOTE origin = new Object(); origin.x = 300; origin.y =
    200; What this does, is it defines the origin to be an object with physical properties such
    as X and Y coordinates and it then sets those coodinates to 300 and 200, which is the center of the
    movie. Now we want to set what is called the 'focalLength'. QUOT....
  7. Flashing Your Motherboard's Bios
    How to flash a BIOS (10)
    Hello Everyone, Let me start with reintroducing myself into this forum. My name is Michael Odo. A
    Nigerian and one of the previous most active members of this great online community. Well, I know
    that I have been off from here for quite a very long time due to some hard times but, I am back now
    and in full force . Back to the topic of my discussion . BIOS means Basic Input/Output System .
    It is a software embedded into your motherboard and which controls everything on your system.
    Flashing the BIOS is quite a risky affair and you are better adviced not to try t....
  8. Using An Actionscript In Flash For Loops
    (0)
    QUOTE When you are dealing with a lot of data, you without a doubt will run into the need to use
    loops. Lets say you would want to attach a movieClip to the stage. If its just a few clips it
    won't form a problem, but what if you wanted to attach a lot more clips? It would be impossible
    to set them up piece by piece. It would take hours of coding the same code over and over again and
    that redundancy is something you could really do without, not even talking about the time you are
    loosing. This is where loops come into action. We have a few different ones to our d....
  9. Making Interactive Cds With Flash
    My second flash tutorial for Beginners (2)
    Im back again with what i think it would be an interesting tutorial for all of you guys who wants to
    take flash out of the web and make really cool interactive CDS. First of all if all of you are
    thinking right now: "this dude is wrong for making interactive cds you have to use macromedia
    Director", well you are right macromedia director it's used to build interactive cds and dvds
    among other things, but you can also make interactive cds with Flash, the thing is: if you want to
    make a simple interactive CD you can totally do it with flash, of course Director brings ....
  10. Tweening In Flash Mx
    Simple tutorial for biginners. (10)
    In this tutorial you will learn how to tween in Flash MX. Motion Tween 1. Create a new
    document in flash. Any size will do. 2. Create any shape or object - just not a Flash UI. 3. On
    the time line right click on the time when you want it to stop moving. right click on a frame and
    click Insert keyframe. 4. Select it, you can use the black picture of a cursor in the toolbox
    (Arrow Tool (v)) 5. With the new Keyframe selected move the object where you want it to move it.
    6. Select the to keyframes with shift. 7. Right click and press Create Motion Tween. 8. Pr....
  11. Speed Up Acrobat Reader Loading
    (21)
    hi friends, Do u get irritated when acrobat reader takes 5/10 seconds to load when you want to open
    a pdf document. There is a way to speed up the loading. 1. Go to the installation folder of acrobat
    reader (C:\program files\adobe\acrobat\reader\.. whatever) 2. Move all the
    files and folders from the "plugins" directory to the "Optional" directory. (I repeat.. cut and
    paste the files NOT copy & paste). Also make sure that acrobat reader is not open else it will lock
    the files and not allow you to move the files). Now your acrobat reader will ....
  12. How To Format Your Flash Disk/ Diskettes
    Formatting your flash or diskette (6)
    Now sometime your flash disk or diskette might have corrupt data, don't worrry just format it.
    follow these simple steps: 1. Double click "My Computer" on your desktop. It opens a window with
    all the available disks. 2. Right-click, your "Removable Disk" or "3 1/2 Floppy" 3. Then click
    "Format" it would bring out a window 4. you can either choose "Quick Format" option to make the
    formatting faster. 5. then click the format buttooon. it formats the drive. When it finishes it
    show you the "format complete" dialog, click "ok" and it is done. you have a formatted d....
  13. Loadsound Flash Mx
    streaming (0)
    I've asked this question in another section but i figure it belongs here. Would like to know if
    it's possible to loop streaming music using loadsound. I've managed to do it by creating a
    movie that loops but i was wondering if there was another way? round.trap17.com....
  14. Flash Movie Loads...
    (4)
    Im making a full flash website... For those flash freaks... I used LoadMovieNum to call the a
    movie1. And then movie1 has submovie1. Submovie1 has subs too... (e.g.sub1) How can i load sub1
    retaining the movie1 & submovie1!? and the is there a way? or is it just one loading of movie at
    a time?? =)....
  15. Flash Tutorials
    (7)
    I have been looking for a complete tutorial on how to do flash. I have found a few but they only
    teach you how to do 1 or 2 certain things. I need one that shows excatly step by step how do do
    everything. If anyone out there knows where to find one like that please let me know. Im not
    looking to learn it overnite i am looking for a long term tutorial that i can work at my own pace.
    Tahnks in advance!....
  16. Flash / Multimedia
    tutorials (1)
    Building a flash site ---------------------------------------- Kirupa.com - Building a complete
    site hyd-designs.com - PHP Nuke and Flash Animating 3D logo with Swift3D
    ---------------------------------------- http://flashmove.com/fsug/session/s...xpress/demo.htm
    Prototypes ---------------------------------------- http://proto.layer51.com/ A huge list of
    resources links ---------------------------------------- http://www.stranger.per.sg/ FLASH
    TUTORIAL LINKS ---------------------------------------- whatdoiknow.org - Flash Presentatio....
  17. Applications, Music, Movies And More
    (0)
    This site below has many movies and music along with programs and web design tools that are all
    free. You have to sign up and post replies to most of the posts to get the hidden text.
    http://www.appheaven.com ....

    1. Looking for loading, movies, technique, flash

Searching Video's for loading, movies, technique, flash
advertisement



Loading Movies Technique In Flash



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE