# Transition of alpha via Action Script

**URL:** <https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405>\
**Category:** classic bestof\
**Created:** [September 15, 2001, 5:17am UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405 "2001-09-15T05:17:13Z")\
**Posts on this page:** 9\
**Page:** 2

<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:** [June 10, 2003, 4:57pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/21 "2003-06-10T16:57:39Z")

</div>

Wow!  
Randomize an array—That’s a very smart move–never thought about it.  
It works wonderful and you are my hero.  
Many thanks!

p.s. why do you call yourself “failed scripter”?

---

<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:** [June 10, 2003, 8:05pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/22 "2003-06-10T20:05:20Z")

</div>

Glad everything works out for ya 😉

And I call myself “failed scripter” because… uhhh… I don’t know 😛

---

<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:** [June 11, 2003, 5:37pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/23 "2003-06-11T17:37:41Z")

</div>

Hi, Lostinbeta:

Knock, knock again. but I hope you do not see me as a pain…

These photos in the gallary is relatively small. If all those images are large sized, say 750 by 420, resulting 900K+ for each image, should I concern about preloader? A preloader loads all images before the movie performs(auto run every 5 seconds, fade in and out…)?  
Please see:  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25488](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25488)

Do I need it?  
If yes, how do I insert them into the code you helped developed so far??

Thanks, you are my only help.

---

<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:** [June 11, 2003, 5:46pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/24 "2003-06-11T17:46:19Z")

</div>

The code already has a built in preloader 😉

You just have to edit it to do what you want.

[AS]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);  
}  
};[/AS]

NOTE: I posted that to help you find it in the script, THIS CODE ALREADY EXISTS IN THE SCRIPT, just making sure you don’t add it twice 😉

---

<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:** [June 12, 2003, 3:06pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/25 "2003-06-12T15:06:28Z")

</div>

I did look at above code, and wondered whether it’s preloader or not, or good enough for handling the larger image…

Thanks a ton, Lostinbeta! you guy rocks!

---

<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:** [June 12, 2003, 3:52pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/26 "2003-06-12T15:52:21Z")

</div>

😉 no problem.

---

<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:** [June 15, 2003, 2:26am UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/27 "2003-06-15T02:26:08Z")

</div>

Hi, LostinBeta:

I am quite happy with what I’ve been helped on this photo gallery so far. But I have my butts kicked by someone who want to add in captioning for each photo and a photo number indicator. I tried and tried and appearantly I am not good enough to pull it out. So I have no where to turn to but you.:\*(

1. caption for each photo:  
I made text file named “animation.txt” with “&image1= this is pea\*\*\*\*, &image2=this is elephant, &image3…” and I put a dynamic text field with instance name of “caption”.

I put this on top of all the code:  
“LoadVariablesNum(“animation.txt”, 0);”  
then I put under “LoadMovie(this.pathtoPics + this.pArray…”:  
“caption.text=eval(this.pArray[0]);”

The text field shows nothing. what is the correct code to make caption.text display the right text for each photo displayed?

1. photo number indicator:  
for each photo displayed, it will show : 1 of 10, 2 of 10, 3 of 10…  
I have 2 text fields with instance names of “currentNum” and “totalNum”. Then at the very end of all the code I put:  
“currentNum.text=this.pIndex;  
totalNum.text=this.pArray.length;”

well, I got totalNum display the correct number, but the currentNum always stay at “1”, no matter how photo has been changed. I guess I missed something, but I could not figure it out. (note: the original file start with image0, for this purpose I want to start with image1, so I changed “this.pIndex=0” to “this.pIndex=1”).

Thanks again, Lostinbeta!

---

<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:** [June 23, 2003, 3:01pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/28 "2003-06-23T15:01:02Z")

</div>

Hi LIB-  
Someone referred me to this thread as a source for using AS to alpha some bitmap images in a fla I am working on. Well I downloaded the fadetest.fla and it works great.  
I was just wondering how to go the opposite way on this- to take an image that is set to alpha 0 and then fade it in.  
:bounce:

---

<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:** [September 15, 2004, 7:17pm UTC](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405/29 "2004-09-15T19:17:32Z")

</div>

Hi there -

This is really great!

I’m just not sure about where the “delete this.onEnterFrame” goes in order to make it not repete -

Can you help?

Thanks!!!

> [@lostinbeta](#):
>
> Here ya go… with an MX update…
> 
> [AS]MovieClip.prototype.fade = function(minAlpha, maxAlpha, speed) {  
> this.onEnterFrame = function() {  
> if (!this.trigger) {  
> this.\_alpha -= speed;  
> if (this.\_alpha\<=minAlpha) {  
> this.\_alpha = minAlpha;  
> this.trigger = true;  
> }  
> } else if (this.trigger) {  
> this.\_alpha += speed;  
> if (this.\_alpha\>=maxAlpha) {  
> this.\_alpha = maxAlpha;  
> this.trigger = false;  
> }  
> }  
> };  
> };  
> clipToFade.fade(0, 100, 5);[/AS]

[Previous page](https://forum.kirupa.com/t/transition-of-alpha-via-action-script/3405.md?page=1)
