# Changing Alpha settings via actionscript

**URL:** https://forum.kirupa.com/t/changing-alpha-settings-via-actionscript/19543
**Category:** flash
**Created:** [April 29, 2003, 2:51am UTC](https://forum.kirupa.com/t/changing-alpha-settings-via-actionscript/19543 "2003-04-29T02:51:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Demerdar](https://avatars.discourse-cdn.com/v4/letter/d/8e7dd6/32.png) [@Demerdar](https://forum.kirupa.com/u/Demerdar)
#### Post date: [April 29, 2003, 2:51am UTC](https://forum.kirupa.com/t/changing-alpha-settings-via-actionscript/19543/1 "2003-04-29T02:51:11Z")

</div>

Hi, i made text into a movie clip and put in this code to adjust the alpha.

onClipEvent (load){  
this.\_alpha=100;  
i=1;  
}  
onClipEvent (enterFrame) {  
if(this.\_alpha=0 && i==0){  
this.\_alpha+=1;  
if(this.\_alpha\>=100){  
i=1;  
}  
}  
else{  
this.\_alpha+=1;  
if(this.\_alpha\<=0){  
i=0;  
}  
}  
}

The alpha is going down… I think, because the text isnt there. What i’m having trouble with is getting it to go back and forth. Increasing and decreasing the alpha when it gets to it’s maximum or minimum. I hope I’m making some sense… Does anyone have any ideas? And no I cannot do this with a simple motion tween because there are things happening in the background.

---

<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: [April 29, 2003, 2:58am UTC](https://forum.kirupa.com/t/changing-alpha-settings-via-actionscript/19543/2 "2003-04-29T02:58:04Z")

</div>

blah what a waist of time; I just had a few syntax errors 😛

---

<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: [April 29, 2003, 3:04am UTC](https://forum.kirupa.com/t/changing-alpha-settings-via-actionscript/19543/3 "2003-04-29T03:04:22Z")

</div>

i gotta go, check this fla…

---

<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: [April 29, 2003, 3:22am UTC](https://forum.kirupa.com/t/changing-alpha-settings-via-actionscript/19543/4 "2003-04-29T03:22:52Z")

</div>

for this type of stuff i usually have a three frame movie clip…two layers, one for content and one for code…frame 1 is init, frame 2 is action, frame 3 is loop (back to frame 2)…for me it cleans the logic up a lil and so i can avoid frame events (they scare me)…

if(this.\_alpha=0 && i==0){  
the first part will always result in a true and set your alpha to zero, use…  
if(this.\_alpha==0 && i==0){

however i is one so the else case is performed first setting alpha to 1…therefore this code kinda thrashes between alpha = 0, i = 1 and alpha = 1, i = 1

any help? rob
