# Random alpha change

**URL:** https://forum.kirupa.com/t/random-alpha-change/59098
**Category:** flash
**Created:** [July 28, 2004, 1:40pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098 "2004-07-28T13:40:56Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![keljnr](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@keljnr](https://forum.kirupa.com/u/keljnr)
#### Post date: [July 28, 2004, 1:40pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/1 "2004-07-28T13:40:56Z")

</div>

Hi people. I want to make each of the squares (pictured below) change alpha every second or so. (fading).

Is actionscript needed to do this? can anyone help?

![](http://www.thelawnetwork.co.uk/test.jpg)

Cheers

---

<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: [July 28, 2004, 1:51pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/2 "2004-07-28T13:51:13Z")

</div>

Use yourMC.\_Alpha = number to set the alpha (do it in a function)  
Use setInterval(functionName, interval) to call the function every “interval”.  
and stop when alpha = 0;  
🙂

---

<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: [July 28, 2004, 1:56pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/3 "2004-07-28T13:56:32Z")

</div>

or…

onEnterFrame = function() {  
myMC.\_alpha = random(0,100);  
}

i think that’s the syntax… 🙂

:p:

---

<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: [July 28, 2004, 2:04pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/4 "2004-07-28T14:04:21Z")

</div>

cheers for the quick responce but i get this error:

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: Wrong number of parameters; random requires exactly 1.  
myMC.\_alpha = random(0,100);

Total ActionScript Errors: 1 Reported Errors: 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: [July 28, 2004, 2:10pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/5 "2004-07-28T14:10:17Z")

</div>

ah… right…

for (var i = 0; i\<=10; i++) {  
ball.duplicateMovieClip(“ball”+i, i);  
ball.\_alpha = random(100);  
ball.\_x = i\*70  
}

there ya go. did that just for you. i’ve got the fla if you wanna see it 😛

:p:

---

<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: [July 28, 2004, 2:12pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/6 "2004-07-28T14:12:08Z")

</div>

function alfachange (targetmc){if(targetmc.\_alpha \>0){targetmc.\_alpha = targetmc.\_alpha - 10}}  
setInterval(alfachange , 1000)

---

<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: [July 28, 2004, 2:12pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/7 "2004-07-28T14:12:30Z")

</div>

thanks!!

yeah, id love ta c the FLA.

cheers.

---

<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: [July 28, 2004, 2:14pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/8 "2004-07-28T14:14:28Z")

</div>

it’s for flash mx 04… lemme know if you need an mx.

---

<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: [July 28, 2004, 2:18pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/9 "2004-07-28T14:18:22Z")

</div>

i have get it to work, but i dont want all those random balls. just 1 ball with a random changing alpha.

cheers

---

<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: [July 28, 2004, 2:19pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/10 "2004-07-28T14:19:58Z")

</div>

ok.

onEnterFrame = function() {  
box.\_alpha = random(100);  
}

throw that on a frame and see what happens. give your squares the instance of box.

:p:

---

<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: [July 28, 2004, 2:25pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/11 "2004-07-28T14:25:03Z")

</div>

thats the one fella, cheers!  
i knew i could rely on you guys.

Is there anyway i could make the alpha fade to the changing alpha instead of it just jerkin?

---

<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: [July 28, 2004, 2:26pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/12 "2004-07-28T14:26:38Z")

</div>

that’s a bit more advanced… let’s see here…

onEnterFrame = function() {  
newAlpha = random(100);  
box.\_alpha += newAlpha;  
}

try that, lemme know.

:p:

//edit, actually, i don’t think that will work… i’ll play w/ it in flash.

---

<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: [July 28, 2004, 2:44pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/13 "2004-07-28T14:44:37Z")

</div>

no it didnt work. but dont need ta mess about with it tho, im happy with the one you gave us before.

thanks alot.

---

<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: [July 28, 2004, 2:44pm UTC](https://forum.kirupa.com/t/random-alpha-change/59098/14 "2004-07-28T14:44:43Z")

</div>

poo… flash sucks… someone else’s gonna have to help ya 😉
