Loading Images

In my flash I have buttons that load a jpg using the actionscript below

on (release) {
_root.createEmptyMovieClip(“container”, 1);
container.loadMovie(“mypicture.jpg”);
container._x =365; container._y=90;

}

is there a way to have preloader until the jpg loads?

I’m new to this so make it simple if possible.

Thanks

lost was working on something like this…

do a search in the MX or ActionScript forums…

Rev

Yep, it can be found here…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15472

So I would put your script above the script I have in my first post? What else do I need to do to make it work (besides change the “yourimage.jpg” to my file?

your script

this.createEmptyMovieClip(“preloader”, 1000);
this.createEmptyMovieClip(“container”, 1001);
container.loadMovie(“yourImage.jpg”);
container._visible = false;
preloader.onEnterFrame = function() {
var l = container.getBytesLoaded();
var t = container.getBytesTotal();
var getPercent = l/t;
loadText = Math.round(getPercent100)+"%";
loadBar._width = getPercent
100;
if (l>0 && l>=t) {
container._visible = 1;
delete this.onEnterFrame;
}
};

Thanks

Well you would need to create the loadBar movie clip and the loadText textbox as well.

Thanks for the help, I put in the loadBar and loadText and here is my script in full. It keeps saying “statement must be within on handler”,

this.createEmptyMovieClip(“preloader”, 1000);
this.createEmptyMovieClip(“container”, 1001);
container.loadMovie(“zz1.jpg”);
container._visible = false;
preloader.onEnterFrame = function() {
var l = container.getBytesLoaded();
var t = container.getBytesTotal();
var getPercent = l/t;
loadText = Math.round(getPercent100)+"%";
loadBar._width = getPercent
100;
if (l>0 && l>=t) {
container._visible = 1;
delete this.onEnterFrame;
}
};
on (release) {
_root.createEmptyMovieClip(“container”, 1);
container.loadMovie(“zz1.jpg”);
container._x =365; container._y=90;

}

Well your code is kind of a bit wrong.

As shown on the second page of the thread I gave you a link to this is how you would load it from a button.

The button must be a movie clip symbol with the instance name “button” (no quotes).

Then apply these actions to a frame…
[AS]this.createEmptyMovieClip(“preloader”, 1000);
this.createEmptyMovieClip(“container”, 1001);
container._x = 365 ;
container._y = 90 ;
container._visible = false;
preloader.onEnterFrame = function() {
var l = container.getBytesLoaded();
var t = container.getBytesTotal();
var getPercent = l/t;
loadText = Math.round(getPercent100)+"%";
loadBar._width = getPercent
500;
if (l>0 && l>=t) {
container._visible = 1;
delete this.onEnterFrame;
}
};
button.onPress = function() {
container.loadMovie(“zz1.jpg”);
};[/AS]

Sidenote: If you want to use a button symbol instead of a movieclip symbol remove this code from the above script…
[AS]button.onPress = function() {
container.loadMovie(“zz1.jpg”);
};[/AS]

And on your button symbol add this code…
[AS]on (release) {
container.loadMovie(“zz1.jpg”);
}[/AS]