dcsimg
A Flash Developer Resource Site

Page 7 of 10 FirstFirst ... 345678910 LastLast
Results 121 to 140 of 189

Thread: For everyone with a preloader problem

  1. #121
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    this is really testing me...

    i've looked through the preloaders on whispers footer (which are really helpful!) and found this code:

    code:
    onClipEvent (enterFrame) {
    tb = math.round(_root.container.getBytesTotal()/1024);
    lb = math.round(_root.container.getBytesLoaded()/1024);
    if (tb>0 && lb>0) {
    this.percent = math.round((lb/tb)*100);
    this.gotoAndPlay(this.percent);
    if (lb>=tb) {
    _root.transition.gotoAndPlay("out");
    _root.preloader.gotoAndStop("stop");
    }

    }
    }



    thing is i understand it all, so had ago on writing my own - it didnt work. so added this scripting instead and it still didnt work.

    i dont have transitions in my work, but my swfs do have intros which i subbed in as a replacement. the code works fine when calling the "play" frame of the preloader - but the preloader does nothing - just sits there and then disappears once the movie's loaded. what went wrong?

    the only thing i could see different was my "pole_clip" didnt have a variable text box - just an animated loaderBar which is 100 frames - it's this animation that's not working - it justs sits on the first frame the entire loading period. surely this code, "this.gotoAndPlay(this.percent);" is telling it to move...?

  2. #122
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    What version of Flash are you using?
    If above MX... ActionScript is case sensitive.

    a couple things to mention:

    1.) onClpiEvent(enterFrame)() is not a good way of coding.. you should NOT put code ON or IN movieClips on the stage. You 'should' put your code in FRAMES in the MAIN timeline.

    so:
    onClipEvent (enterFrame)():
    should be more like:
    someClip.onEnterFrame = function(){};

    2.) all mentions/reference of _root should be converted to relative paths/scope (ie: this, this._parent, _parent...etc)


    3.) case sensitive.... this where I believe YOUR problem lies..


    math.round should be Math.round()..

    Code:
    onClipEvent (enterFrame) {
    	tb = Math.round(_root.container.getBytesTotal()/1024);
    	lb = Math.round(_root.container.getBytesLoaded()/1024);
    	if (tb>0 && lb>0) {
    		this.percent = Math.round((lb/tb)*100);
    		this.gotoAndPlay(this.percent);
    		if (lb>=tb) {
    			_root.transition.gotoAndPlay("out");
    			_root.preloader.gotoAndStop("stop");
    		}
    	}
    }

    4.) I suggest looking into using the MovieClipLoader() class.. it it is VERY (very) useful for triggering actions when content is loaded as well as providing data for any preloder.


    update:

    here is a quick example of how to use the MovieClipLoader() class..


    simplified version:
    PHP Code:

    // create our MovieClipLoader instance (called: contentLoader)
    var contentLoader:MovieClipLoader = new MovieClipLoader();

    //create an object to handle the data available form the MovieClipLoader() object.
    var contentListener:Object = new Object();

    // create function that fires/executes when the content starts loading
    contentListener.onLoadStart = function(target_mc:MovieClip):Void {
        
    trace(">> contentListener.onLoadStart()");
    }
    // create function that fires/executes each time a byte/potion is loaded (preloader)
    contentListener.onLoadProgress = function(target_mc:MovieClipbytesLoaded:NumberbytesTotal:Number):Void {
        
    trace(">> contentListener.onLoadProgress()");
    }
    // create function that fires/executes when the content is complete
    contentListener.onLoadComplete = function(target_mc:MovieCliphttpStatus:Number):Void  {
        
    trace(">> contentListener.onLoadComplete()");
    };
    // create function that fires/executes when the content has initialized and is ready for manipulation
    contentListener.onLoadInit = function(target_mc:MovieClip):Void  {
        
    trace(">> contentListener.onLoadInit()");
    };


    // add our 'listener' object to our MovieClipLoader instance
    contentLoader.addListener(contentListener);


    // create an empty movieClip on the stage to hold our content...(this can be any target you want though)
    var containerClip:MovieClip this.createEmptyMovieClip("containerClip"this.getNextHighestDepth());

    // finally, make the call to load whatever content we want.. this is just an on-line image (but can be whatever, .swf, .jpg, clips in library..etc)
    contentLoader.loadClip("someIMage.jpgg"containerClip); 



    PHP Code:
    //create an object to handle the data available form the MovieClipLoader() object.
    var contentListener:Object = new Object();
    // create function that fires/executes when the content is complete
    contentListener.onLoadProgress = function(target_mc:MovieClipbytesLoaded:NumberbytesTotal:Number):Void {
        
    trace(target_mc._name ".onLoadProgress with " bytesLoaded " bytes of " bytesTotal);
        
    trace(">> Invoked every time the loading content is written to the hard disk during the loading process (that is, between MovieClipLoader.onLoadStart and MovieClipLoader.onLoadComplete).");
    }
    // create function that fires/executes when the content is complete
    contentListener.onLoadComplete = function(target_mc:MovieCliphttpStatus:Number):Void  {
        
    trace(">> contentListener.onLoadComplete()");
        
    trace(">> =============================");
        
    trace(">> "+target_mc._name+"._width: " target_mc._width);
        
    trace(">>> {its 0 because the content hasnt (although complete) hasnt initiliazed and Flash can not access any properties.}");
        
    trace(newline);
    };
    // create function that fires/executes when the content has initialized and is ready for manipulation
    contentListener.onLoadInit = function(target_mc:MovieClip):Void  {
        
    trace(">> contentListener.onLoadInit()");
        
    trace(">> =============================");
        
    trace(">> "+target_mc._name+"._width: " target_mc._width);
        
    trace(">>> {its 315 because once the content/clip has initialized, Flash can not access its properties.}");
        
    trace(newline);
        
    // Draw outline around the loaded content
        
    target_mc._x Stage.width/2-target_mc._width/2;
        
    target_mc._y Stage.height/2-target_mc._width/2;
        var 
    w:Number target_mc._width;
        var 
    h:Number target_mc._height;
        
    target_mc.lineStyle(40x000000);
        
    target_mc.moveTo(00);
        
    target_mc.lineTo(w0);
        
    target_mc.lineTo(wh);
        
    target_mc.lineTo(0h);
        
    target_mc.lineTo(00);
        
    target_mc._rotation 0;
    };

    // create our MovieClipLoader instance (called: contentLoader)
    var contentLoader:MovieClipLoader = new MovieClipLoader();
    // add our 'listener' object to our MovieClipLoader instance
    contentLoader.addListener(contentListener);
    // create an empty movieClip on the stage to hold our content...(this can be any target you want though)
    var containerClip:MovieClip this.createEmptyMovieClip("containerClip"this.getNextHighestDepth());
    // finally, make the call to load whatever content we want.. this is just an on-line image (but can be whatever, .swf, .jpg, clips in library..etc)
    contentLoader.loadClip("http://www.w3.org/Icons/w3c_main.png"containerClip); 

  3. #123
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    thanks - some interesting bed time reading...

    edit: it's flash 8 i'm using.

  4. #124
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    actually - that's worked a treat! it was the case sensitive thing you mentioned- thanks whispers...

    also i'll be adding the php code to my list of things to take a heavy interest in - it looks a little out of my depth at the moment (although a lot of things did before i started using this site )

  5. #125
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    well if yoru using Flash 8..then the Math.round() is/was the problem...

    and the above MovieClip loader is VERY simple... it just looks like a lot of code.

    in its simplest form.. you could just do this:
    PHP Code:
    var containerClip:MovieClip this.createEmptyMovieClip("containerClip"this.getNextHighestDepth());
    var 
    contentLoader:MovieClipLoader = new MovieClipLoader();
    contentLoader.loadClip("http://www.w3.org/Icons/w3c_main.png"containerClip); 
    but your not assigning a listener to watch for the totalBytes/loadBytes, not to trigger any actions once the content has initialized.

  6. #126
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    Quote Originally Posted by inquizard
    actually - that's worked a treat! it was the case sensitive thing you mentioned- thanks whispers...

    also i'll be adding the php code to my list of things to take a heavy interest in - it looks a little out of my depth at the moment (although a lot of things did before i started using this site )
    hi there is NO PHP, I just wrapped the code in some PHP tags on the forum so the action script is color coded and easier to read..

    its ALL actionscript..

    just take the code open a new .fla and paste that in there.. and tst nothign else needs to be done.

  7. #127
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    Quote Originally Posted by whispers
    hi there is NO PHP, ...
    that's it i'm going to bed!

    thanks again whispers for your help - i came across your posts about not putting a preloader in the loading swf. ended up changing my site today because of it and seemed to have solved a problem before i realised it for a change.

    edit: OMG i just tried your code and i now have alot more to think about... and i was so looking forward to other stuff tomorrow
    Last edited by inquizard; 09-24-2007 at 04:40 PM.

  8. #128
    Junior Member
    Join Date
    Nov 2003
    Posts
    14
    hello there,
    i have this code for my preloading, it works fine, but this one waits for the
    entire site to load, how can i modify it, for a certain certain number of frames
    to be loaded and the move on.

    PHP Code:
    loadPercent = (Math.floor(_root.getBytesLoaded()/_root.getBytesTotal()*100)+"%");

    if (
    _root.getBytesLoaded() == _root.getBytesTotal()) {    //Check for finished loading
        //If loaded, final update to fields
        
    loadPercent "100%";
        
        
    gotoAndPlay("Scene 1"1);    //Where to go once your movie is loaded

    thanks

  9. #129
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    your preloader is calculating PERCENTAGES.... you could check for a certain percentage instead of 100%..

    or you could not use getBytesLoaded()/getBytesTotal()....

    and use MovieClip._frameloaded property...
    example:
    if (this._framesloaded < this._totalframes) {
    this.gotoAndPlay(1);
    } else {
    this.gotoAndStop(3);
    }




    (similar to the old deprecated ifFrames loaded code)
    example:

    ifFrameLoaded([scene:String], frame) {
    //statement(s);
    }

  10. #130
    Junior Member
    Join Date
    Sep 2007
    Location
    United States
    Posts
    11
    i have kind of a problem and i feel like a noob for it lol
    i have no clue how to make my song play when the movie starts
    ive tried everything i can think of, and i know it cant be that difficult
    can somebody help me?

  11. #131
    Junior Member
    Join Date
    Nov 2003
    Posts
    14
    I again,
    i got mad with this problem i have this code more 3 times
    i each of them calls for a movieclip, and each movie has a preloading in it,
    and it works fine... on the computer... not in the site i don't know
    why, i know that you must have every .swf file in the same folder of the main
    .swf file, everything works fine with the "CTRL - Enter" or after i publish,
    but after i uploaded every .swf, it just didn't work, the preloading works for
    the main, but then when i rollover each button, the browser bar where the
    "waiting for http://www.site.com..." appears, it shows that but nothing
    happens. I also tried with internet explorer, and nothing shows.

    i was so happy that i've finaly got it, and now

    here's the code, did i missed something, i really don't get it
    why does not work in the web, if it does in windows?

    PHP Code:
    stop();
    this.createEmptyMovieClip("empty_mc",1);
    button1.onRollOver = function() {
        
    empty_mc.loadMovie("GSB.swf");
        
    empty_mc._xscale "101.1";
        
    empty_mc._yscale "101.1";
        
    empty_mc._x "0";
        
    empty_mc._y "-6.5";
    }; 

  12. #132

  13. #133
    Junior Member
    Join Date
    Nov 2003
    Posts
    14
    i thought that much i choose this instead because the first one that i
    used, was MovieClipLoader() but it did work, the percentage was not showing.
    I'll give it another try. thanks

  14. #134
    Junior Member
    Join Date
    Nov 2003
    Posts
    14
    HI AGAIN PEOPLE

    I did it, found the problem it was simple, the path was wrong:

    "GSB.swf" - wrong

    "/images/stories/GSB.swf" - right



    thanks a lot for everything

  15. #135
    Junior Member
    Join Date
    Sep 2007
    Posts
    1
    hi
    i've got a bit of a problem.
    i've created a web site in flash, and have structured it so that there is one movie with a navigation bar in it, which when you click a button, this opens the content, which are .swf files, in a content loader.
    there are preloaders displayed before the content is displayed as some .swf files are a little large and the user needs to see that the content is being loaded, othewise they would be inclined to think that nothing is happening, and so leave the website.

    the problem is that in firefox, the preloaders do not show at all, in explorer they do now and again.

    this is the site address:- www.bird272.com

    thanks alot for any help from you guys/girls.

    PEEEEEEEEEEEACE

  16. #136
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    For me, the preloaders show fine in Firefox 2, XP, SP2.

    ~Sportzguy933

  17. #137
    Junior Member
    Join Date
    Oct 2007
    Posts
    24

    Preloader display?

    Hi all,

    This is an extensive post on preloaders. learnt quite a number of things here. Thanks for sharing.

    Here are my questions on my situation. hehe. I have a number of external swfs and a main swf that has containers to hold the external swfs.

    1) If I were to create a preloader in the main swf, would the totalbytes be main swf + the rest of my external swfs in the containers or just the main swf?

    The next qn is alittle off but I do hope to get an answer. Thanks in advance.

    2) My main swf will have 3 containers, to load external swfs namely, banner (at top), menu (at middle) , content (at bottom). I have an intro external swf to be displayed after the preloader which is before the banner, menu and content and the position of this intro.swf will be covering the entire position of all the 3 swfs (banner, menu, content).
    In order to do the above, can i create a large container in the main swf for the intro.swf after the preloader and then add a command to gotoframe(x) which will have the 3 containers to load the 3 external swfs. So it means that main.swf will have 1 large container at maybe frame3 and then 3 small containers at frame4.

    would that be possible? I am still planning stage, no product yet. Stuck at planning so do not know whether if its possible.

    Thanks alot.

  18. #138
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    1.) the preloader will check the totalBytes/loadedBytes for whatever TARGET you point it to 'watch/check' ..

    You can have 3 preloaders in the MAIN.swf for example...

    1 that runs displays when the movie starts..to show howmuch of the main movie is being loaded..

    but you can also have those other prleoaders watch empty/blank movieClips so when you load your external.swf's into them... it will only check the totalBytes of the content being loaded into THAT target and how muchg of it has been currently loaded...


    2.) yes you can do it that way.. I would look into using the movieClipLoader() class.. as it has callback you can use to trigger your actions once the things are started to start, on each onProgress, on complete and on Initi (also onError)...

  19. #139
    Senior Member
    Join Date
    Oct 2007
    Posts
    146
    Have you tried the Fonzy method of hitting the computer- in the right spot, of course.

    -westink

  20. #140
    Junior Member
    Join Date
    Oct 2007
    Posts
    24
    Hi whispers,

    thanks for answering my post.

    However, I don't understand this portion.

    "1 that runs displays when the movie starts..to show howmuch of the main movie is being loaded.."

    Hopefully I can do 1 preloader to load all my mcs and that the progress bar will reflect the loading of the total size of the main mc and the external mcs. For example, my banner.swf = 50kb, menu.swf=25kb, content.swf=500kb, intro.swf=200kb. I have checked and asked around and read that I can use arrays and moviecliploader to load them one by one. But if I were to load them one by one, my drawn preloader that will display the progress by revealing the logo, will be repeated a number of times based on the number of mcs that I be loading. Can I have it to gathered all the size and then load them and do the progress animation once only?

    does the moviecliploader have a function of doing so or I got to do it manually by getting the size of the all the mcs, add them up, then let them be the total size, and use bytesloaded divided by this total size and reflect it in my progress bar? You think is possible?

    thanks.

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