#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Preloader gets stuck? What wrong with it?


    I have a flash website and I am using this code on the first frame for the preloader

    Code:
    stop();
    import flash.display.*;
    
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, preloadme);
    function preloadme(event:ProgressEvent):void {
    
    var percentcalc:Number=event.bytesLoaded/event.bytesTotal*100;
    bar.x=percentcalc/100;
    if(pcent==100){
    this.gotoAndPlay(2);
    }
    }
    It doesnt work properly when I open my website with FireFox from my hard drive, but when I load it onto a server, it will work but a new problem occurs. Once it is loaded in Firefox once, when you try to load that website again in FF, it does not move from the first frame and gets stuck. I have to clear the Firefox cache for it to work properly.

    It works alright in Chrome. It sometimes get stuck in Opera.

    Anyone know why this happens?

    Im thinking maybe there is something wrong with the code. It is waiting for data to be loaded but because it is already in the cache of FF, no data will be loaded and so it gets stuck.

    Any help thanks : ))
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Hi, you've got:

    var percentcalc

    but then you check:

    if(pcent == 100)

    That should be:

    if(percentcalc== 100)
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0
    Originally Posted by Tann San
    Hi, you've got:

    var percentcalc

    but then you check:

    if(pcent == 100)

    That should be:

    if(percentcalc== 100)
    Thank you for the reply Tann Sann : )

    I made the change and it still has the same problems : ((

    Does this happen because my Flash website is 8mb?
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Are you certain you cleared your cache so that you are using the latest version? Size shouldn't matter if you are using a preloader, that is the whole point of using one ^_^

    You should also listen for the Event.COMPLETE event. That gets called once the file has finished loading. If it's being loaded from the cache then it may not call your progress event handler at all. It also means you can get rid of the if condition and just have the gotoAndPlay in the COMPLETE event handler function you write:
    Code:
    this.loaderInfo.addEventListener(Event.COMPLETE, loadingComplete);
    function loadingComplete(event:Event):void
       {
          this.gotoAndPlay(2);
       }
    Quis custodiet ipsos custodes?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0
    Thanks Tann for the code.

    I tried it, but in IE and Firefox it still has the same issues. In Safari and in Chrome, there are no problems.

    This is the full script I am using now
    Code:
    stop();
    import flash.display.*;
    import flash.events.Event;
    
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, preloadme);
    function preloadme(event:ProgressEvent):void {
    
    var percentcalc:Number=event.bytesLoaded/event.bytesTotal*100;
    bar.x=percentcalc/100;
    if(percentcal<=99){
    funnyAnim_mc.gotoAndPlay(2);
    }
    }
    
    this.loaderInfo.addEventListener(Event.COMPLETE, loadingComplete);
    function loadingComplete(event:Event):void
       {
          this.gotoAndPlay(2);
    bar.x=100;
       }
    I have a little animation movie while it loads called funnyAnim_mc

    Any idea what could be happening or what else to fix this?
  10. #6
  11. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    isn't funnyAnim_mc going to mess up since you are gotoAndPlaying its 2nd keyframe every time the progress is updated. Something like this might help with that:

    if(funnAnim_mc.currentFrame == 1 && percentcal <= 99)

    So is the problem with FF and IE that it works the first time but then on the second viewing it remains stuck on the first keyframe?
    Quis custodiet ipsos custodes?
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0
    Oh yes, thanks Tann about funnyAnim_mc.

    I was trying to figure that one out.

    In FF, it plays the flash website the first time but if you go to another site and back to the flash website again, it gets stuck.

    It seems to work alright on certain IE8. On my friend's PC with IE8, it doesn't have those issues and on my PC it does... hmm
  14. #8
  15. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Well what do you see when it gets stuck? Do you see the progress bar at all? Do you have anything that outputs the percent loaded to the screen? It's hard to say what could be wrong without more information.
    Quis custodiet ipsos custodes?
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0
    Originally Posted by Tann San
    Well what do you see when it gets stuck? Do you see the progress bar at all? Do you have anything that outputs the percent loaded to the screen? It's hard to say what could be wrong without more information.
    The loading bar doesnt move. Its stuck on 0 and just flashes.

    Its stuck on the first frame I think.
  18. #10
  19. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Does funnyAnim_mc animate? At the moment we're just trying to guess what is wrong, we need some better feedback. Put a textfield on the stage and make your different functions write to it so you can see what it going on under the hood.
    Quis custodiet ipsos custodes?
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0
    Originally Posted by Tann San
    Does funnyAnim_mc animate? At the moment we're just trying to guess what is wrong, we need some better feedback. Put a textfield on the stage and make your different functions write to it so you can see what it going on under the hood.
    Hello again Tann : )

    I have removed the funnyAnim_mc, just to isolate what is causing what. As I suspected, the funnyAnim_mc makes no difference, my flash movie still gets stuck in Firefox once it is loaded once or my flash movie gets stuck if you open the website directly from the hard drive.

    I do not understand why it would work on Chrome and IE 8+ but has issues in Firefox.
  22. #12
  23. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    I asked if funnyAnim_mc animated as that would tell us if the preloader progress event was getting called and if its state was below 99%. I still say you should add a textfield to the stage and append text to it so we can see what is happening at each stage of the loading process.
    Quis custodiet ipsos custodes?
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0
    Sorry for the late reply, I have just been caught up with school and work.

    I tried the text field and definitely not going past the first frame of the preloader.

    What do you think Tann?
  26. #14
  27. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Try outputting the percentcalc, event.bytesLoaded and event.bytesTotal values to the textfield from within the preloadme function. What are their values? Do they get written out several times or just once? Put a line in the loadingComplete function to see if that is getting called at all.
    Quis custodiet ipsos custodes?

IMN logo majestic logo threadwatch logo seochat tools logo