# Need help, have a bug with image loader

**URL:** <https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342>\
**Category:** flash\
**Created:** [June 5, 2008, 8:37am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342 "2008-06-05T08:37:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bahoo](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bahoo](https://forum.kirupa.com/u/bahoo)\
**Post date:** [June 5, 2008, 8:37am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/1 "2008-06-05T08:37:45Z")

</div>

have a big problem with one site that have just finished.  
i’m not a master in action scripting, i used a simple image loader class with action script 2 with preloader, it works well, preloads and loads the image perfectly.  
**the problem** is that after a while (maybe 1 mn) the image disappers.

here is the code i used:

[COLOR=Red]bar2.\_visible = false;  
per2.\_visible = false;

this.createEmptyMovieClip(“container2”, “100”);  
my\_mc2= new MovieClipLoader();  
preload2 = new Object();  
my\_mc2.addListener(preload2);  
preload2.onLoadStart = function(targetMC2) {

//trace("started loading "+targetMC);  
container2.\_visible = false;  
bar2.\_visible = true;  
per2.\_visible = true;  
pText2.\_visible = true;

};  
preload2.onLoadProgress = function(targetMC2, l2Bytes, t2Bytes) {

bar2.\_width = (l2Bytes/t2Bytes)\*100;  
per2.text= "Loading: % "+Math.round((l2Bytes/t2Bytes)\*100);

};  
preload2.onLoadComplete = function(targetMC2) {

targetMC2.\_visible = true;  
targetMC2.\_alpha = 0;  
targetMC2.onEnterFrame= function(){targetMC2.\_alpha+=10};  
per2.\_visible = false;  
bar2.\_visible = false;  
pText2.\_visible = false;  
//trace(targetMC+" finished");

};  
my\_mc2.loadClip(“img/01.jpg”, “ima”);

//default image  
b1.onPress=function(){my\_mc2.loadClip(“img/01.jpg”, “ima”);}  
b2.onPress=function(){my\_mc2.loadClip(“img/02.jpg”, “ima”);}  
b3.onRelease=function(){my\_mc2.loadClip(“img/03.jpg”, “ima”);}  
b4.onRelease=function(){my\_mc2.loadClip(“img/04.jpg”, “ima”);}  
b5.onRelease=function(){my\_mc2.loadClip(“img/05.jpg”, “ima”);}  
b6.onRelease=function(){my\_mc2.loadClip(“img/06.jpg”, “ima”);}

[COLOR=Black]please can someone help me!!:pa:[/COLOR]  
[/COLOR]

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 5, 2008, 10:23am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/2 "2008-06-05T10:23:07Z")

</div>

targetMC2.onEnterFrame= function(){targetMC2.\_alpha+=10

that doesn’t seem healthy you should tween from 0 to 100, not enterframe with no delete command

there aint that much code… I doubt what is wrong is within what is above

---

<div class="post-metadata">

**Author:** ![bahoo](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bahoo](https://forum.kirupa.com/u/bahoo)\
**Post date:** [June 6, 2008, 8:23am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/3 "2008-06-06T08:23:00Z")

</div>

thank you for replying.  
“ima” is the movieclip where the images are loaded.  
the loading works well, but the real problem is that the image disappears after a while (1 mn).

---

<div class="post-metadata">

**Author:** ![bahoo](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bahoo](https://forum.kirupa.com/u/bahoo)\
**Post date:** [June 6, 2008, 8:27am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/4 "2008-06-06T08:27:34Z")

</div>

thank you **randomagain**

i will try this even if i ever used the function “tween” before.  
its time to begin.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 6, 2008, 9:45am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/5 "2008-06-06T09:45:44Z")

</div>

[http://www.kirupa.com/developer/actionscript/tween.htm](http://www.kirupa.com/developer/actionscript/tween.htm)

I was dubious at first, but it is so much easier,

I can only suggest there is a set interval, delete, unload, alpha, \_visible

somewhere in your code which is wiping out the images

---

<div class="post-metadata">

**Author:** ![excogitator](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@excogitator](https://forum.kirupa.com/u/excogitator)\
**Post date:** [June 6, 2008, 9:50am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/6 "2008-06-06T09:50:18Z")

</div>

Btw this is your problem in your code  
targetMC2.\_alpha+=10

Your alpha value is exceeding 100 and keeps incrementing 10 even though unnecessary.  
When it exceeds 900 or so your movieclip will dissappear. Add a condition for 100 or use tweens as randomagain has mentioned.

Hope that solves your predicament.

---

<div class="post-metadata">

**Author:** ![bahoo](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bahoo](https://forum.kirupa.com/u/bahoo)\
**Post date:** [June 7, 2008, 4:53pm UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/7 "2008-06-07T16:53:27Z")

</div>

thank you for helping me,  
i will try this and inform you about the results.

---

<div class="post-metadata">

**Author:** ![bahoo](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@bahoo](https://forum.kirupa.com/u/bahoo)\
**Post date:** [June 11, 2008, 9:39am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/8 "2008-06-11T09:39:29Z")

</div>

thanks to **excogitator** i found the metter with my code.  
i added the condition for 100 and it solves the problem.

thanks to everybody, for your help.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 11, 2008, 9:41am UTC](https://forum.kirupa.com/t/need-help-have-a-bug-with-image-loader/262342/9 "2008-06-11T09:41:51Z")

</div>

I said that 😜
