# \[AS3\]Randomly do something without repeat

**URL:** <https://forum.kirupa.com/t/as3-randomly-do-something-without-repeat/327714>\
**Category:** flash\
**Created:** [March 22, 2012, 10:57am UTC](https://forum.kirupa.com/t/as3-randomly-do-something-without-repeat/327714 "2012-03-22T10:57:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pizza0502](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pizza0502](https://forum.kirupa.com/u/pizza0502)\
**Post date:** [March 22, 2012, 10:57am UTC](https://forum.kirupa.com/t/as3-randomly-do-something-without-repeat/327714/1 "2012-03-22T10:57:09Z")

</div>

Hi,

I’ve 3 movieclip on stage which is mc1,mc2,mc3  
at first they are alpha=0

What I want is when i click on revealBtn, 1 of them will show up as alpha=1.

But with my code below, sometimes I need to click about 5 times or more only can make all those mc show up.

Is there any solution for what I wanted?

```auto
var mcArray:Array = [mc1,mc2,mc3];
for (var j:int = 0; j < mcArray.length; j++)
{
	mcArray[j].alpha = 0;
}

revealBtn.buttonMode = true;
revealBtn.useHandCursor = false;
revealBtn.addEventListener(MouseEvent.CLICK, revealClick);

function revealClick(event:MouseEvent):void
{
	//Generate random number (integer) between 0 and mcArray.length
	var i:Number = Math.floor(Math.random() * mcArray.length);

	//Select ith element of mcArray
	var movieClipToEdit:MovieClip = mcArray* as MovieClip;

	//Change its alpha to 1
	movieClipToEdit.alpha = 1;
}

```
