A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [CS3] Ok, I must be dumb...

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Posts
    19

    [CS3] Ok, I must be dumb...

    And i know this issue has been addressed millions of times on this board, but I am having preloader issues! I've tried to use code from existing tutorials on the site but nothing seems to be working.

    Here's my deal.....
    I have a main .swf basically containing my navigation which loads in the smaller .swf's into level 1....(its about 5 subsequent swf files) In my knowledge, I've built another "Preloader" animation (similar to the Apple start-up star thing that will just spin until the loading is complete) .FLA file that the main Navigation .swf loads by "loadMovieNum("Preloader.swf",1)" to be published that will look for the total bytes of the other subsequent .swf and play on until the file is completely loaded.

    I've built it this way because I've read that having the preloader in the same .swf file that is attempting to be load is not good. Someone please help before my boss has my head! Thanks in advance..

  2. #2

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Posts
    19
    Sorry....Looking for some simple preloader code that will allow my pre-build animation to just sit there and spin until the .swf file it's looking for is loaded...

    That's it!

    Thanks

  4. #4
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    I thought that but wasn't 100% sure This should get you started:

    Just call using: loadMyClip("myfile.swf", container_movieclip);

    PHP Code:
    var mcl:MovieClipLoader=new MovieClipLoader;
    var 
    mclObj:Object=new Object;
    preloader_mc._visible false;

    function 
    loadMyClip(path:Stringtarget_mc:MovieClip):Void {
        
    mcl.loadClip(path,target_mc);
        
        
    mclObj.onLoadStart=function(target_mc) {
            
    preloader_mc._visible true;
            
    preloader_mc.play();
        };
        
    mclObj.onLoadInit=function(target_mc) {
            
    preloader_mc._visible false;
            
    preloader_mc.gotoAndStop(1);
        };
    };

    mcl.addListener(mclObj); 

  5. #5
    Junior Member
    Join Date
    Apr 2008
    Posts
    22
    Quote Originally Posted by sstalder
    I thought that but wasn't 100% sure This should get you started:

    Just call using: loadMyClip("myfile.swf", container_movieclip);

    Having a similar issue with a "built-in" preloader, so I'm going to create a separate .swf...just two quick questions (as I'm a bit of a newbie):

    1. Why do you attach a listener at the end of your code?
    2. Why do you use onLoadInit instead of onLoadComplete for displaying/hiding the preload ani?

    Thanks!

  6. #6
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    1. There is no real reason other than preference. I could of just as easily put the listener at the top but I don't like doing that personally.
    2. I stripped out alot of code in this but when I use it I sometimes need to set / get properties of the loaded movieclip which is why I do not use onLoadComplete, but for your uses you may be able to.

    To help you understand better (taken from adobe.com):

    It's important to understand the difference between MovieClipLoader.onLoadComplete and MovieClipLoader.onLoadInit. The onLoadComplete event is called after the SWF, JPEG, GIF, or PNG file loads, but before the application is initialized. At this point, it is impossible to access the loaded movie clip's methods and properties, and therefore you cannot call a function, move to a specific frame, and so on. In most situations, it's better to use the onLoadInit event instead, which is called after the content is loaded and fully initialized.

  7. #7
    Junior Member
    Join Date
    Apr 2008
    Posts
    22
    Thanks much...slowly starting to figure this stuff out.

    onLoadInit seems to be the way to go.

  8. #8
    Junior Member
    Join Date
    Apr 2008
    Posts
    22
    One more question...

    If my preloader_mc is actually a progress bar (with percentage), what is the best way to define totalbytes/loadedBytes, and pass those values into onLoadProgress?

    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center