A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Help: how to detect/preload external .jpg

  1. #1
    Member
    Join Date
    Oct 2000
    Location
    san franacisco, ca
    Posts
    43
    I'm loading some external .jpg's into a slideshow. I need to preload them before I start showing them and then making them transition into the next image. Any Ideas? I'll be loading several into frame one. Then the slideshow will start on frame three, say. so how do I keep it looping till they all are done loading? external .jpg's are important here so they can be updated witout flash. thanks!

    --Dave

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    106
    This should help you on your way:

    http://actionscript-toolbox.com/samplemx_loadjpg.php

    Good luck

  3. #3
    Member
    Join Date
    Oct 2000
    Location
    san franacisco, ca
    Posts
    43

    thats (almost) it, but not quite!

    I need to load multipule .jpg's I like how that one waits for the .jpg to load before displaying it. that should be uesful but the problem is that if i load a second .jpg with the function it will replace the first.

    I'm trying to work on that code so that it gives each "holder" MC the same name as the .jpg file I'm importing.

    Also I see that its loading the programatically generated empty MC into level one. it looks like level one is replaced by each generated emptyclip. is that what it is doing? can each generated empty clip remain on level 0 with a different mane? that would be nice! as opposed to replacing the entire level, if that's what its doing.

    here's the code on frame1

    MovieClip.prototype.loadjpg = function(picName) {
    this.createEmptyMovieClip("holder", 1);
    this.holder.loadMovie(picName);
    this.onEnterFrame = function() {
    if (this.holder.getBytesLoaded() > 1 && this.holder.getBytesLoaded() >= this.holder.getBytesTotal()) {
    delete this.onEnterFrame;
    this.onComplete();
    }
    }
    }

    this next code is used to bring in an image using the above function. its on a keyframe or a button:

    function positionIt() {
    this._x = 50;
    this._y = 50;
    }

    this.createEmptyMovieClip("myjpg", 1);
    myjpg.onComplete = positionIt;
    myjpg.loadjpg("jumpman.jpg");

    //jumpman is the name and location of the actual .jpg file to be loaded.


    if anyone of you flash pros can help me to modify that code to generate differently named emptyClips with thier own names like one, two, three, .etc, that can recieve multipule .jpg's loaded off the server I would be VERY grateful!

    THANKS!



  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    106
    I'm trying to work on that code so that it gives each "holder" MC the same name as the .jpg file I'm importing.
    Sorry can't write any more at the moment, got a meeting to go too. But this should do the trick??:

    Code:
    var myJpegName_array = new Array("first", "second", "anotherone", "yetanotherone"); //jpeg filename minus the .jpg, NB.\ don't think it will work with spaces in the name
    
    for (var i = 0; i < myJpegName_array.length; i++){
    	this.createEmptyMovieClip(myJpegName_array[ i], 1+i); 
    	eval(myJpegName_array[ i]).onComplete = positionIt; 
    	eval(myJpegName_array[ i]).loadjpg(myJpegName_array[ i]+".jpg"); 
    }

  5. #5
    Member
    Join Date
    Oct 2000
    Location
    san franacisco, ca
    Posts
    43
    Originally posted by Tidey
    I'm trying to work on that code so that it gives each "holder" MC the same name as the .jpg file I'm importing.
    Sorry can't write any more at the moment, got a meeting to go too. But this should do the trick??:

    Code:
    var myJpegName_array = new Array("first", "second", "anotherone", "yetanotherone"); //jpeg filename minus the .jpg, NB.\ don't think it will work with spaces in the name
    
    for (var i = 0; i < myJpegName_array.length; i++){
    	this.createEmptyMovieClip(myJpegName_array[ i], 1+i); 
    	eval(myJpegName_array[ i]).onComplete = positionIt; 
    	eval(myJpegName_array[ i]).loadjpg(myJpegName_array[ i]+".jpg"); 
    }



    thanks! I'll try working with that code.
    thanks again
    --Dave

  6. #6
    Senior Member
    Join Date
    Mar 2000
    Posts
    116
    bump

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