# Controlling alpha with as

**URL:** https://forum.kirupa.com/t/controlling-alpha-with-as/23227
**Category:** Uncategorized
**Created:** [June 14, 2003, 11:35pm UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227 "2003-06-14T23:35:24Z")
**Posts on this page:** 12
**Page:** 1

<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 14, 2003, 11:35pm UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/1 "2003-06-14T23:35:24Z")

</div>

what would be the best way to control a mc’s alpha with actionscript. i need to be able to fade a mc with various buttons

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: [June 14, 2003, 11:55pm UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/2 "2003-06-14T23:55:36Z")

</div>

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

---

<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 14, 2003, 11:55pm UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/3 "2003-06-14T23:55:45Z")

</div>

[AS]function alphaFade(clipToFade, finalAlpha, speed) {  
clipToFade.onEnterFrame = function() {  
this.\_alpha += (finalAlpha-this.\_alpha)/speed;  
if (Math.floor(this.\_alpha) == Math.floor(finalAlpha)) {  
this.\_alpha = finalAlpha;  
delete this.onEnterFrame;  
}  
};  
}  
myButtonInstanceName.onPress = function() {  
alphaFade(myMovieClip, 20, 10);  
};[/AS]

If you don’t want to use dynamic event handlers you can just use  
[AS]on (press) {  
alphaFade(myMovieClip, 20, 10);  
}[/AS]

Change the parameters to whatever you want. myMovieClip is the clip you want to fade, 20 is the final alpha value, and 10 is the speed of the fade.

I hope this helps.

---

<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 14, 2003, 11:57pm UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/4 "2003-06-14T23:57:07Z")

</div>

> \*Originally posted by Ilyas \*  
> \*\*[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=4016](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=4016) \*\*

Posted at the same time 😛

---

<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 14, 2003, 11:59pm UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/5 "2003-06-14T23:59:20Z")

</div>

thank you guys! ya know i saw soemthing about this the other day but i couldn’t find the post #

---

<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, 12:00am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/6 "2003-06-15T00:00:10Z")

</div>

> \*Originally posted by Digitalosophy \*  
> \*\*thank you guys! ya know i saw soemthing about this the other day but i couldn’t find the post # \*\*

Thats the glory of [http://www.kirupaforum.com/forums/search.php?s=](http://www.kirupaforum.com/forums/search.php?s=) 😉

---

<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, 12:06am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/7 "2003-06-15T00:06:57Z")

</div>

lol ya man i know about the search, as if your header wasn’t good enough. thanks the script worked very well. this will come n super handy 🙂

---

<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, 12:10am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/8 "2003-06-15T00:10:54Z")

</div>

hmm having a problem. i have buttons which are inbeded into movie clips. i am tryin gto refer to the mc as

[AS]  
on(release){  
\_root.about\_destination = 85;  
alphaFade(\_root.header, 20, 10);  
}

[/AS]

dang i know this is a silly one but could ya give me a hand?

---

<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, 12:19am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/9 "2003-06-15T00:19:35Z")

</div>

Can you describe what is embeded in what exactly?

---

<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, 12:20am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/10 "2003-06-15T00:20:36Z")

</div>

never mind by using dynamic event handlers there is no problem… thanks again. but i had a movie clip with a button embeded in it that i wanted to control the mc that fades

---

<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, 12:33am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/11 "2003-06-15T00:33:35Z")

</div>

Since it is a regular function and not a prootype you would need to target the timeline the function is on.

So \_root.alphaFade(\_root.header, 20, 10); probably would work.

---

<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, 12:36am UTC](https://forum.kirupa.com/t/controlling-alpha-with-as/23227/12 "2003-06-15T00:36:24Z")

</div>

ahh ok thanks
