# Fading in loaded swf

**URL:** <https://forum.kirupa.com/t/fading-in-loaded-swf/204911>\
**Category:** Uncategorized\
**Created:** [October 24, 2006, 3:30pm UTC](https://forum.kirupa.com/t/fading-in-loaded-swf/204911 "2006-10-24T15:30:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)\
**Post date:** [October 24, 2006, 3:30pm UTC](https://forum.kirupa.com/t/fading-in-loaded-swf/204911/1 "2006-10-24T15:30:28Z")

</div>

Hi all,

I have a holder\_mc that I’m loading a swf into, and I wanted it to fade in. I’ve done this code.

The prototype works fine in other situations. so I’m pretty sure it’s not that.  
Do i need to make sure the swf is fully loaded before doing something with it.

[AS]  
MovieClip.prototype.fadeIn = function(speed) {  
this.onEnterFrame = function() {  
this.\_alpha += speed;  
if (this.\_alpha\>=100) {  
this.\_alpha == 100;  
this.onEnterFrame = null;  
}  
};  
};  
holder\_mc.\_alpha = 0;  
one\_btn.onRelease = function() {  
holder\_mc.loadMovie(“image.swf”);  
holder\_mc.fadeIn(10);  
};

[/AS]

---

<div class="post-metadata">

**Author:** ![rhamej](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@rhamej](https://forum.kirupa.com/u/rhamej)\
**Post date:** [October 24, 2006, 9:41pm UTC](https://forum.kirupa.com/t/fading-in-loaded-swf/204911/2 "2006-10-24T21:41:34Z")

</div>

[quote=coop;1984418]Hi all,  
Do i need to make sure the swf is fully loaded before doing something with it.  
[/quote]

Yes =)

---

<div class="post-metadata">

**Author:** ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)\
**Post date:** [October 24, 2006, 10:10pm UTC](https://forum.kirupa.com/t/fading-in-loaded-swf/204911/3 "2006-10-24T22:10:12Z")

</div>

I tried it, but still no success, is there something wrong with my method of testing

[AS]  
MovieClip.prototype.fadeIn = function(speed) {  
this.onEnterFrame = function() {  
this.\_alpha += speed;  
if (this.\_alpha\>=100) {  
this.\_alpha == 100;  
this.onEnterFrame = null;  
}  
};  
};  
holder\_mc.\_alpha = 0;  
one\_btn.onRelease = function() {  
myLoader();  
};  
myLoader = function () {  
holder\_mc.loadMovie(“image.swf”);  
var loaded = holder\_mc.getBytesLoaded();  
var total = holder\_mc.getBytesTotal();  
if (loaded/total==1) {  
holder\_mc.fadeIn(10);  
trace(“here”)  
}  
};  
[/AS]

---

<div class="post-metadata">

**Author:** ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)\
**Post date:** [October 25, 2006, 9:14am UTC](https://forum.kirupa.com/t/fading-in-loaded-swf/204911/4 "2006-10-25T09:14:39Z")

</div>

I tried loading into another clip inside the holder\_mc, but still no luck

help.

[AS]  
MovieClip.prototype.fadeIn = function(speed) {  
this.onEnterFrame = function() {  
this.\_alpha += speed;  
if (this.\_alpha\>=100) {  
this.\_alpha == 100;  
this.onEnterFrame = null;  
}  
};  
};  
holder\_mc.\_alpha = 0;  
one\_btn.onRelease = function() {  
myLoader();  
};  
myLoader = function () {  
myClip = holder\_mc.createEmptyMovieClip(“myHolder”, 1);  
trace(myClip instanceof MovieClip);//true  
myClip.loadMovie(“image.swf”);  
myLoadCheck();  
};  
myLoadCheck = function () {  
trace(“check”);  
myClip.onEnterFrame = function() {  
var Loaded = this.getBytesLoaded();  
var Total = this.getBytesTotal();  
if (Loaded/Total == 1) {  
this.fadeIn(10);  
trace(myClip instanceof MovieClip);//true  
}  
};  
};  
[/AS]

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 25, 2006, 2:03pm UTC](https://forum.kirupa.com/t/fading-in-loaded-swf/204911/5 "2006-10-25T14:03:51Z")

</div>

[QUOTE=coop;1985036]I tried loading into another clip inside the holder\_mc, but still no luck

help.

[AS]  
MovieClip.prototype.fadeIn = function(speed) {  
this.onEnterFrame = function() {  
this.\_alpha += speed;  
if (this.\_alpha\>=100) {  
this.\_alpha == 100;  
this.onEnterFrame = null;  
}  
};  
};  
holder\_mc.\_alpha = 0;  
one\_btn.onRelease = function() {  
myLoader();  
};  
myLoader = function () {  
myClip = holder\_mc.createEmptyMovieClip(“myHolder”, 1);  
trace(myClip instanceof MovieClip);//true  
myClip.loadMovie(“image.swf”);  
myLoadCheck();  
};  
myLoadCheck = function () {  
trace(“check”);  
myClip.onEnterFrame = function() {  
var Loaded = this.getBytesLoaded();  
var Total = this.getBytesTotal();  
if (Loaded/Total == 1) {  
this.fadeIn(10);  
trace(myClip instanceof MovieClip);//true  
}  
};  
};  
[/AS][/QUOTE]  
maybe

```auto
function myLoader() {
	myClip = holder_mc.createEmptyMovieClip("myHolder", 1);
	trace(myClip instanceof MovieClip);
	//true
	myClip.loadMovie("image.swf");
	myLoadCheck();
};
 function myLoadCheck() {
	trace("check");
	holder_mc.onEnterFrame = function() {
		var Loaded = this.myHolder.getBytesLoaded();
		var Total = this.myHolder.getBytesTotal();
		if (Loaded/Total == 1) {
			this.fadeIn(10);
			trace(myClip instanceof MovieClip);
			//true
		}
	};
};

```
