loadMovie() + preloader + resize PROBLEM

Hi, I’ve been messing around for about 4 days and can’t seem to fix the following problem. It’s a big story… but any help would be very very welcome!!!

  1. I’ve got a complete flash-site that loads all content (text & graphics dynamically through PHP).

  2. When clicking on a certain button in a movieclip, I use loadMovie() to load a JPG into a certain target movieclip. There is absolutely no problem in doing this…

  3. However, I want to resize any JPG - after loading (!) - to a certain width / height. If you’ve got a fast connection like ADSL or CABLE it is possible to change _width and _height of that “host” movieclip a couple of frames later. But that does not always function properly! I assume that is because flash never knows when the JPG is completely loaded; i.e. when the loadMovie() is not yet done, the _width and _height of the target clip are 0, so there’s no point doing any calculations.

  4. I’ve tried to use the getBytesTotal() vs getBytesLoaded() in a function that is called onClipEvent(enterFrame, etc.), but that doesn’t seem to make any sense. I’m sure I need a preloader for movies / JPGs that are loaded DYNAMICALLY.

  5. Then I found a really efficient preloader (http://moock.org/asdg/codedepot/preloadManager.fla) that solves the nr. 3 & 4 problem: the JPG can be resized correctly because flash is sure it is completely loaded. I slightly changed the code of the preloadManager function to do just that. BUT…

  6. that preloader only seems to work on the _root. I need the same functionality within the targetMovie. I can’t seem to change the script to make it work within a movieclip.

  7. I’ve tried to use the preloader on stage and then attach the loaded moveclip (or JPG) to my correct target; but the attachMovie() method is limited to mcs stored in the library!

if this wouldn’t be clear:
I’m looking for an effective preloader or some mechanism that tells me when my dynamic JPG outside the main flash is done loading, so I can manipulate it.

PLZ HELP.

Hey,

This code should help.

onClipEvent (enterFrame) {
if (totalBytes==undefined) {
totalBytes = this.getBytesTotal();
}
loadedBytes = this.getBytesLoaded;
remainingBytes = loadedBytes-totalBytes;
percent = int(this.getBytesLoaded()/this.getBytesTotal() * 100);
//Make a dynamic text field with this variable
_root.percentoutput = percent + “%”;
}
You place this code on the target movieclip that you are loading your jpg into and the dynamic text field named percentoutput will show when its reached 100%. This should solve your problem.

Good Luck

Kyle

Nope, that is what I described in NR4 (first post)… I tried that and understand what it does, but does not function.

Meanwhile I found another loading mechanism that sort of does the job (http://actionscript-toolbox.com/samplemx_loadjpg.php).
I modified this script to suit my needs, but when I load more than one JPG at a time… it never works. I can’t seem to figure out why it loads a certain JPG and than it doesn’t function with another.

Yep, that method at actionscript-toolbox’s is the right one. But I don’t think that you can load several jpg at a time. It’s just not possible. And why would you want that anyway ?

pom :asian:

isn’t there a way to load them one at a time? I tried that… but again sometimes it loads the JPG and sometimes it doesnt.

Why I need that??? I definitely need it. (Read NR3 in the first post!) I can’t resize a JPG or movieclip that has not been loaded completely. I’ve tried dozens of tricks and workarounds… but there is no resonable explanation for the fact that flash is very picky on loading external files… If I seem to wait long enough before I load any other JPG(s), the chances that the image will be displayed are better!

Download-speed is my concern: on a cable or dsl connection the JPG loads quite fast… but I don’t know how fast/slow that same JPG will load elsewhere - before I can resize it!

All I can say is that it is causing me a terrible headache.

:*(

I don’t understand. Didn’t you say that you did something similar to what they say on that site, AS-Toolbox ? Because that’s exactly what you need. There’s no problem of waiting whatsoever.

According to a fla I have, you don’t even need to wait

_root.createEmptyMovieClip("container_mc",1);
container_mc.loadMovie("image.jpg");
container_mc._x = container_mc._y = 20;
container_mc._xscale = container_mc._yscale /= 4;

But if it doesn’t work, this HAS TO WORK :

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();
            }
       }
}

function resizeIt() {
    this._xscale = 50;
    this._yscale = 50; 
}

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

pom :asian: