A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: loading external jpegs w/ buttons

  1. #1
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399

    loading external jpegs w/ buttons

    For example I have a target mc named "target_mc" and I have a image that would load per button. Now I've dealt with regular preloaders, and sound class preloaders, but I'm kinda confused as to how-to preload the jpeg loading percentage into a dynamic textfield, this kinda reminds me of making a basic mp3 preloader as shown below, any suggestions would be great.

    sound_1 = new Sound();
    sound_1.loadSound("http://themakers.com/sounds/atmospheres_1.mp3", true);
    function checkLoad(){
    var percentLoaded = (sound_1.getBytesLoaded()/sound_1.getBytesTotal())*100;
    progress.text = Math.round(percentLoaded)
    message.text = "MEK - Far From Home";

    }
    checkProgress = setInterval(checkLoad, 1000);
    Last edited by TRJNET; 06-02-2004 at 03:16 PM.
    consultant / contractor / designer

  2. #2
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399
    k I remember someone on here showing me an example of how-to load any jpeg on fly dynamically w/ some slick AS on a button:

    So just say i had a list of buttons, each button would call & load a jpeg dynamically from the same directory, my trouble is figuring out the proper AS to make that jpeg preload and show the percentage in a dynamic textfield named "percent" and the main target mc would be called "target_mc", heres a site with good examples of this method being used throughout the site:

    http://www.n-graph.com/hello.html
    Last edited by TRJNET; 06-03-2004 at 02:11 PM.
    consultant / contractor / designer

  3. #3
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399
    hmmm the coding that Im trying to get working for this list of buttons would similiar to this, the target MC is named "target_mc" and the dynamic textfield instance name is "percent":




    on (release) function
    target_mc.loadMovie("cat.jpg")
    var percentLoaded = (target_mc.getBytesLoaded()/target_mc.getBytesTotal())*100;
    percent.text = Math.round(percentLoaded)

    }

    -----------------------------------
    So the script above would go on each button, and for the example above, upon button release, it will load the jpeg dynamically and also show the download progress percentage into a dynamic textifeld. Now you might be wondering why would anyone need this, 2 reasons:

    It's a good method to make flash photo galleries, and it only downloads the pictures that the user wants to see (on the listing) therefore making the overall movie less in weight for file size and not needing to preload every image with the rest of movie, versus downloading specific files when needed while still viewing the flash movie. So in general, its a good method for the fact it doesnt force the flash client to download everything which they might not want to see.
    Last edited by TRJNET; 06-03-2004 at 02:11 PM.
    consultant / contractor / designer

  4. #4
    Member
    Join Date
    Nov 2001
    Posts
    32

    i'm having trouble with that too

    i've got the same situation.

    the problem i'm seeing is that... getBytesLoaded() and getBytesTotal()used on the empty mc(holderClip) that gets the jpg loaded into it are both equal to 0 when the script checks them... therefore it assumes its loaded and skips ahead.

    i'm trying this ...

    //blah
    holderClip.loadMovie("img.jpg");
    //blah
    if(holderClip.getBytesLoaded() < holderClip.getBytesTotal()){
    gotoAndPlay(blah);
    }else{
    gotoAndPlay(blah);
    }


    but when it check ... they both equal 0, so it plays instead of waiting. grrr.
    Fine and Digital Artist
    http://www.stacymark.com

  5. #5
    Member
    Join Date
    Nov 2001
    Posts
    32
    hmm... this seems to work for me. i added another check to see if getBytesLoaded() < 1 to make sure its not comparing 0 to 0.


    if (loadedBytes < totalBytes || loadedBytes < 1) {
    gotoAndPlay("blah");
    } else {
    gotoAndPlay("blah");
    }
    Fine and Digital Artist
    http://www.stacymark.com

  6. #6
    Japanese l337 TRJNET's Avatar
    Join Date
    Mar 2001
    Location
    Toronto, Canada
    Posts
    399
    Originally posted by TRJNET
    heres a site with good examples of this method being used throughout the site:

    http://www.n-graph.com/hello.html
    I checked out the AS for that site using a decompiler and I found out that example, wasn't preloading jpegs but it was really loading swf's dynamically and have a preloader in each external swf, I found it quite interesting and I tested it out for myself and realized, what's the point of loading jpegs when u can load swf's which can do more Plus it was easier to use swf's that have their own preloaders.

    I'll post a link to my prototype when it's ready.
    consultant / contractor / designer

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