# Loading photo with fade effect

**URL:** https://forum.kirupa.com/t/loading-photo-with-fade-effect/262708
**Category:** flash
**Created:** [June 9, 2008, 11:44am UTC](https://forum.kirupa.com/t/loading-photo-with-fade-effect/262708 "2008-06-09T11:44:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![madcobra](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@madcobra](https://forum.kirupa.com/u/madcobra)
#### Post date: [June 9, 2008, 11:44am UTC](https://forum.kirupa.com/t/loading-photo-with-fade-effect/262708/1 "2008-06-09T11:44:01Z")

</div>

Hi,

I’m trying to load a picture with this actionscript.

this.pathToPics = “”;  
this.pArray = [“guy2.png”];  
this.fadeSpeed = 80;  
this.pIndex = 0;

loadMovie(this.pathToPics+this.pArray[0], \_root.photo);  
MovieClip.prototype.changePhoto = function(d) {

this.pIndex = (this.pIndex+d)%this.pArray.length;  
if (this.pIndex\<0) {  
this.pIndex += this.pArray.length;  
}  
this.onEnterFrame = fadeOut;  
};  
MovieClip.prototype.fadeOut = function() {  
if (this.photo.\_alpha\>this.fadeSpeed) {  
this.photo.\_alpha -= this.fadeSpeed;  
} else {  
this.loadPhoto();  
}  
};  
MovieClip.prototype.loadPhoto = function() {

// root waar hij foto vandaan haalt  
var p = \_root.photo;  
//------------------------------------------  
p.\_alpha = 0;  
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);  
this.onEnterFrame = loadMeter;  
};  
MovieClip.prototype.loadMeter = function() {  
var i, l, t;  
l = this.photo.getBytesLoaded();  
t = this.photo.getBytesTotal();  
if (t\>0 && t == l) {  
this.onEnterFrame = fadeIn;  
} else {  
trace(l/t);  
}  
};  
MovieClip.prototype.fadeIn = function() {  
if (this.photo.\_alpha\<100-this.fadeSpeed) {  
this.photo.\_alpha += this.fadeSpeed;  
} else {  
this.photo.\_alpha = 100;  
this.onEnterFrame = null;  
}  
};

Why is’my fade effect not working???

---

<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 9, 2008, 11:56am UTC](https://forum.kirupa.com/t/loading-photo-with-fade-effect/262708/2 "2008-06-09T11:56:11Z")

</div>

use tween class, manual coding stuff like that is daft

been on flash devils recently? 😛
