# Loading Images

**URL:** <https://forum.kirupa.com/t/loading-images/16357>\
**Category:** flash\
**Created:** [March 24, 2003, 4:14am UTC](https://forum.kirupa.com/t/loading-images/16357 "2003-03-24T04:14:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DForm](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@DForm](https://forum.kirupa.com/u/DForm)\
**Post date:** [March 24, 2003, 4:14am UTC](https://forum.kirupa.com/t/loading-images/16357/1 "2003-03-24T04:14:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 4:18am UTC](https://forum.kirupa.com/t/loading-images/16357/2 "2003-03-24T04:18:26Z")

</div>

lost was working on something like this…

do a search in the MX or ActionScript forums…

Rev ![](http://www.aulman.com/rev.gif)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 4:21am UTC](https://forum.kirupa.com/t/loading-images/16357/3 "2003-03-24T04:21:22Z")

</div>

Yep, it can be found here…

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 5:10am UTC](https://forum.kirupa.com/t/loading-images/16357/4 "2003-03-24T05:10:07Z")

</div>

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(getPercent_100)+"%";  
loadBar.\_width = getPercent_100;  
if (l\>0 && l\>=t) {  
container.\_visible = 1;  
delete this.onEnterFrame;  
}  
};

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 5:21am UTC](https://forum.kirupa.com/t/loading-images/16357/5 "2003-03-24T05:21:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 5:37am UTC](https://forum.kirupa.com/t/loading-images/16357/6 "2003-03-24T05:37:11Z")

</div>

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(getPercent_100)+"%";  
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;

}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 5:42am UTC](https://forum.kirupa.com/t/loading-images/16357/7 "2003-03-24T05:42:37Z")

</div>

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(getPercent_100)+"%";  
loadBar.\_width = getPercent_500;  
if (l\>0 && l\>=t) {  
container.\_visible = 1;  
delete this.onEnterFrame;  
}  
};  
button.onPress = function() {  
container.loadMovie(“zz1.jpg”);  
};[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 5:45am UTC](https://forum.kirupa.com/t/loading-images/16357/8 "2003-03-24T05:45:33Z")

</div>

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]
