dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] Preloader only loads once..

Hybrid View

  1. #1
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546

    resolved [RESOLVED] Preloader only loads once..

    Hi all

    I'm having a bit of a strange problem with my preloader today. I've made a preloader wich works as any other regular preloader (just a 100 frame loading animation, but with some extra's after those frames) and which is controlled by AS on the main timeline using two EventListeners attached to the loaderInfo.

    (Link here, but you'd better read first )

    The first one calculates the percentage and tells the preloader to gotoAndPlay that number.

    The second one catches the complete event and tells the pop-up text (which I forgot to mention; it's just a MC which start playing when the frame is entered) to continue to play (bounce down again).

    At the end of the pop-up text timeline, there's this code:

    Code:
    MovieClip(parent).pl.play();
    which tells the preloader to start playing again (remember the extra frames I mentioned above). At the end of that there's this code:

    Code:
    MovieClip(parent).play();
    which obviously makes the main timeline running again.

    PROBLEM: When I upload the swf, the loader works, but when I refresh the window, it shows the full preloader, but then refuses to do anything :s

    If anyone needs more code or something, let me know, and thanks for reading my way too long explanation
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  2. #2
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Ok, so I decided to post the code right away, so that you don't have to ask it, if you're too lazy for that

    Code:
    //Variable for storing percentage
    var percent:int = 0;
    
    // Aligning & resizing the preloader called "pl"
    pl.x = 0;
    pl.y = stage.stageHeight/2 - pl.height/2;
    pl.width = stage.stageWidth;
    
    // Aligning the pop-up text "LOADING"
    m.x = 0;
    m.y = stage.stageHeight/2 - m.height/2;
    
    // Ad some EventListeners
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
    loaderInfo.addEventListener(Event.COMPLETE, completeListener);
    
    function progressListener(e:ProgressEvent):void
    {
    	// Keep track of the percentage
    	var loaded:Number = e.bytesLoaded / e.bytesTotal;
    	percent = loaded * 100;
    
    	// Have the preloader stop at framenumber = to percentage
    	pl.gotoAndStop(percent);
    }
    
    function completeListener(e:Event):void
    {
    	// Tell pop-up message to play
    	m.play();
    	
    	// Remove the eventlisteners
    	loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressListener);
    	loaderInfo.removeEventListener(Event.COMPLETE, completeListener);
    }
    So again, when "m" has reached it's end, it's making itself invisible and then tells the preloader to play it's animation, which will then tell the main movie to play, when it has reached it's end.
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  3. #3
    Junior Member
    Join Date
    Jun 2008
    Posts
    9
    Are you hitting reload before the SWF loads completely by any chance? That could be the bug I'm seeing (see my other post about nasty bug hang).

  4. #4
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Thanks for the reply cyberben3d!

    If I leave it on the "not-doing-anything"-point for a while and hit reload, it sporadically does the right thing, but most of the time (95%), it doesn 't really do anything.
    Closing down the browser completely doesn't make any difference too.

    Same problem in FireFox and Safari (I'm in a Mac).

    Can anyone please try the link and hit reload a few times, checking every time if the preloader does anything?

    If not, then I guess I'm going to have to change the script and make up with an other way of preloading...

    I've tried to replace Event.COMPLETE EventListener with and Event.ENTER_FRAME, and checking for a percent == 100, but that didn't work either ..
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  5. #5
    Junior Member
    Join Date
    Jun 2008
    Posts
    9
    If I allow it to load completely, and then hit reload, it doesn't come up, but it doesn't hang the browser either. Justs sits at 0% I think.

    If I hit reload during the progress bar, it hangs, but that is this Flash bug which has already been identified.

  6. #6
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Ok, I tried to remove the extra ballast I gave the flash move (a big picture in a frame which isn't used in the movie; for testing purpose), but that made the loadbar lose all functionality.

    And so I added the picture again, reuploaded to my server, and now it's not working at all :s

    Flash is really strange sometimes
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  7. #7
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Changed all of the script to this:

    Code:
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING);
    
    function PL_LOADING(event:ProgressEvent):void
    {
    	var pcent:Number = Math.round(event.bytesLoaded/event.bytesTotal*100);
    	
    	pl.gotoAndStop(pcent);
    	
    	if (pcent==100)
    	{
    		m.play();
    	}
    }
    Which is much shorter, and which ... doesn't really help me out .. bugger
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  8. #8
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    So, a day has gone by and still no one with a solution!

    Aren't there any flash guru type of guys online right now?

    I want to send you the files if you think you can solve it, but you have to see the actual files to help ..
    If that's the case, send me a PM!

    I'll be continuing the website, but without a wirking preloader, it's kind of useless, so this will have to be solved someday..

    Oh, if anyone of you guys thinks "wel hey, the methods you use should work, but I'm using a different one and it has never failed me', please post YOUR code, so I can try it out!
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

  9. #9
    lemon juice hurts your eyes florianvanthuyn's Avatar
    Join Date
    Jul 2005
    Location
    Merelbeke, Belgium
    Posts
    546
    Found it, thank you cyberben3d for being the only person responding
    Florian Vanthuyne

    WAR AGAINST SOLVED THREADS
    mark yours as Resolved under Thread Tools!

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