PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] Load Movie with preloader problem
A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: [RESOLVED] Load Movie with preloader problem

  1. #1
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971

    resolved [RESOLVED] Load Movie with preloader problem

    Hello guys! Sorry for my noobness xD

    I have my game, with a preloader in the first frame, that when reaches 100% go to 2nd frame. That works great.

    Now i made a container/parent swf, that loads that swf, with fullscreen options, and when the child swf loads, it loses its preloading action and goes directly to frame 2. I know i call my child swf by the instance name of its the movieclip container/loader but i dont know where to put the prealoder.

    In my parent/loader swf, i have the loader movieclip, instance name "mainholder" and inside of it i have the "subholder" movieclip, which is the responsible of loading my child swf. In the main timeline, on the first frame i have this:

    Actionscript Code:
    mainholder.subholder.loadMovie("mychild.swf");

    My preloading script is:

    Actionscript Code:
    function cargando() {

    total = _root.getBytesTotal();

    cargados = _root.getBytesLoaded();

    //"Math.floor"
    porcentaje = Math.floor((cargados*100)/total);

    prelouder._width = porcentaje;



    if (cargados == total) {

    clearInterval(hiloPrecarga);

    _root.gotoAndStop(2);
    }
    }
    var hiloPrecarga = setInterval(cargando, 1);

    stop();

    Help?

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    You will probably need to do MovieClipLoader()
    that way you need not have any preloaders in your clips, just the main one.

    plenty of MovieClipLoader() threads lately

    .

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    OK, i learned the MovieClipLoader(), the loadClip, the onLoadInit, the onLoadProgress and all that. I managed to apply it to my parent swf. Now the problem is the worst...all my child's swf variables and functions doesn't work. What's going here? Don't tell me I have to change all the script to use things like "global" or my parent swf loader/container movieclip's instance name????? O_o thanks

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi,

    are you trying to access the SWF's variable OUTSIDE onLoadInit? If so, then that might be the problem, because its variables won't be accessible until after it's been loaded into your main SWF, so, try accessing them inside onLoadInit
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Ok ok ok, i kinda "think" i understand what i have to do.

    If on my child swf, my game, i have these variables
    Actionscript Code:
    pressed=false;
    rooms=4;
    item1PICKED=false;

    Then in my PARENT swf, the loader, in the onLoadInit i refer ALL MY CHILD SWF VARIABLES to it:
    onLoadInit=function(){
    thispressed=ContainerMovieClip.pressed;
    thisrooms=ContainerMovieClip.rooms;

    thisitem1PICKED=ContainerMovieClip.item1PICKED;

    }

    Right? :'( i wanna cry

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Yeah, that should work, if you've remembered to add that listener to the MovieClipLoader instance :P

    Also, event handlers, such as onLoadInit, they come with additional parameters you can use, for instance, for onLoadInit, you can get the target movieclip like this:

    Actionscript Code:
    someListener.onLoadInit = function(target){
        trace(target.pressed); // same as ContainerMovieClip.pressed
    }

    You can name it whatever you want, you could instead of naming it 'target', just name it 'someVar', and then change in the code from target.pressed to someVar.pressed and the result would've been the same
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Never mind Nig! Anyway, thanks for that, now I know how to call variables into a loaded movieclip.

    But my issue was solved , removing all the "_root" from my variables, functions and objects!!!! Now when I load my child swf (my game) into the parent swf (the container, loader, with the fullscreen functions) IT'S ALL WORKING!!!!!!

    Now...i still want to know something. In my child swf, if i have a movieclip, and inside that movieclip i have some script that i want to call someting in the main timeline, insted of "root" should I use "_global" or the container movieclip instance name?
    Last edited by angelhdz; 07-10-2012 at 11:40 AM.

  8. #8
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Now i need a little help with this.

    I created a .swf only with all the game's sounds imported into the library with an identifier name. Then, i loaded that movieclip into my game swf, and i want to call the sounds. I tried

    Actionscript Code:
    this.newlevel = soundsMoveClip.newlevel;
    this.music = soundsMoveClip.music;
    this.windowslide = soundsMoveClip.windowslide;

    In my sounds swf, i have this on the first frame:
    Actionscript Code:
    newlevel=new Sound();
    newlevel.attachSound("newlevel");

    music=new Sound();
    music.attachSound("music");

    windowslide=new Sound();
    windowslide.attachSound("windowslide");

    But not succes. Any ideas?
    Last edited by angelhdz; 07-10-2012 at 10:12 PM.

  9. #9
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Hello again! I understand now the movieclipLoader and all its functions, but my game is not loading 100%. I managed to hide the swf until its 100% loaded, then it shows up, but some sounds and elements (objects, text) are not being loaded.
    Actionscript Code:
    function callLoadClip(clip:String):Void
    {

    var mcLoader:MovieClipLoader = new MovieClipLoader();

    var listener:Object = new Object();

     

    listener.onLoadStart = function(target:MovieClip) {



    }
     

    listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void
    {
    var percent:Number = Math.round(bytesLoaded * 100 / bytesTotal);
    preloader_txt.text = percent + "%";
    prelouderMC.prelouder._width=percent;
    subholder._visible=false;

    }
     
    // Loaded
    listener.onLoadInit = function(target:MovieClip) {


    prelouderMC._visible=false
    subholder._visible=true;
    }

     
    // Init
    mcLoader.addListener(listener);
    mcLoader.loadClip(clip, subholder);
    }
     
     
    // Call function
    //
    callLoadClip("eskapate.swf");

  10. #10
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    *Bump*

  11. #11
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Here is the same code slightly modified:

    Actionscript Code:
    var timing:Number;
    prelouderMC.timing=0;

    mcLoader= new MovieClipLoader();

    var listener:Object = new Object();

     mcLoader.addListener(listener);

    listener.onLoadStart = function(target:MovieClip) {
    trace("started loading "+target);
    subholder._visible=false;
    eskapate.swf
    }
     

    listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void
    {
    var percent:Number = Math.round(bytesLoaded * 100 / bytesTotal);
    preloader_txt.text = percent + "%";
    prelouderMC.prelouder._width=percent;

    prelouderMC.timing = percent;
    }
     
    // Loaded
    listener.onLoadComplete = function(target:MovieClip) {


    prelouderMC._visible=false
    subholder._visible=true;
    }

     
    // Init

    mcLoader.loadClip("eskapate.swf", subholder);

    It still doesn't load some sounds and graphics. It's weird, the preloading reaches 100% and everything seems to be loaded, but not. The starting music doesn't load, the sounds of the 3rd level, neither.

  12. #12
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    your loader seems ok

    Actionscript Code:
    stop();

    var timing:Number;
    prelouderMC.timing = 0;

    mcLoader = new MovieClipLoader();
    listener = new Object();
    mcLoader.addListener(listener);

    listener.onLoadStart = function(target:MovieClip)
    {
        trace("started loading " + target);
        subholder._visible = false;
        //eskapate.swf;
    };
    listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void
    {
        var percent:Number = Math.round(bytesLoaded * 100 / bytesTotal);
        preloader_txt.text = percent + "%";
        prelouderMC.prelouder._width = percent;
        prelouderMC.timing = percent;
    };
    listener.onLoadComplete = function(target:MovieClip)
    {
        prelouderMC._visible = false;
        subholder._visible = true;
    };
    listener.onLoadInit = function(target:MovieClip)
    {
        // Do what ever you like;
    };

    mcLoader.loadClip("eskapate.swf",subholder);

    but tis hard to tell whats going on without being able to use the files.

  13. #13
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Ok, here is the Holder.fla and a "testing.swf" with a sound. In the testing.swf, there is sound. When loaded it with the holder.fla, no sound.

    http://www.mediafire.com/?1hivddu6gj1a60j

  14. #14
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    it works two ways.

    first is
    swap
    Actionscript Code:
    mcLoader.loadClip("testing.swf", subholder);

    for
    Actionscript Code:
    mcLoader.loadClip("testing.swf", 0;
    that works but screws up your preloader and other things

    the other way and better way is put your sounds in the holder.swf library and give them identifier names, you can remove them from testing.swf

  15. #15
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Great fruitbeard! Copy/pasting the sounds from child swf to parent swf library did the job.

    But what about sharing the library between swf's? I reed something about that, and in the library panel i saw Export For Runtime Sharing.

  16. #16
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Not too knowledgable about runtime sharing stuff, i have looked at that before but never really needed to use it.
    hundreds of explanations about it on the web though.

    fruitbeard the friendly douche bag

  17. #17
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Loooooooooolllllllllllllllllllllllll you make me really laugh a lot! Thank you very much, i will read about this.

    Hey about your site, maybe you can add an option to change toolbars color, that would be really nice love the fullscreen button, the buttons TOP or BOTTOM position changer, and the preloader

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