A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: browser compatibility issue

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Posts
    10

    browser compatibility issue

    Hi

    I've been using the code below to load pictures, then play the movie once the image is fully uploaded. It works fine in IE, but not in Firefox? Firefox starts to play the movie before the image is loaded. Can anyone please advise?
    Thanks,
    Mike
    (ps - I'm not an expert on actionscript, so please try to make it simple)


    stop();
    onEnterFrame = function() {
    startLoading("images/photo1.jpg");
    };
    function startLoading(whichimage) {
    loadMovie(whichimage, this.imageLoader);
    onEnterFrame = function() {
    infoLoaded = this.imageLoader.getBytesLoaded();
    infoTotal = this.imageLoader.getBytesTotal();
    percentage = Math.floor(infoLoaded/infoTotal*100);
    if(percentage>=100) {
    this.play();
    delete this.onEnterFrame;
    }
    };
    }

  2. #2
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    try this:

    PHP Code:
    startLoading("images/photo1.jpg");

    function 
    startLoading(whichimage) {
        
    loadMovie(whichimagethis.imageLoader);
        
    onEnterFrame = function () {
            
    infoLoaded this.imageLoader.getBytesLoaded();
            
    infoTotal this.imageLoader.getBytesTotal();
            
    percentage Math.floor(infoLoaded/infoTotal*100);
            if (
    percentage>=100 && infoTotal != 0) {
                
    this.play();
                
    delete this.onEnterFrame;
            }
        };

    I have no idea how the code you posted was working at all... you had the function call (startLoading) in an onEnterFrame which should have made your preloader go in to an infinite loop as it's trying to load the image many times a second, makes no sense. I removed that and added && infoTotal != 0 to your if statement.

    Here's why I added that - say the user is on a very slow connection. startLoading is ran but before the image has began downloading the infoLoaded variable would return '0' for filesize until it knows how big it is which would mean percentage would equal 100% as 0/0 * 100 = 100. So it basically just ensures that the preloader won't be ignored.. Nice for bad connections and just maybe it will fix your issue!

    good luck!
    Evolve Designs Interactive Media
    the natural selection

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Posts
    10
    Thanks for your help - it seems to have done the trick!

    Regards

    Mike

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