# How make random mc without array ? as3

**URL:** <https://forum.kirupa.com/t/how-make-random-mc-without-array-as3/329456>\
**Category:** Uncategorized\
**Created:** [August 31, 2012, 3:22am UTC](https://forum.kirupa.com/t/how-make-random-mc-without-array-as3/329456 "2012-08-31T03:22:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oskil](https://avatars.discourse-cdn.com/v4/letter/o/e47774/32.png) [@Oskil](https://forum.kirupa.com/u/Oskil)\
**Post date:** [August 31, 2012, 3:22am UTC](https://forum.kirupa.com/t/how-make-random-mc-without-array-as3/329456/1 "2012-08-31T03:22:45Z")

</div>

this my code : :q:  
import flash.utils.Timer;  
import flash.events.TimerEvent;

var num\_count:Number=0;  
var txt\_score: TextField = new TextField();  
var merah:Merah = new Merah;  
var hijau:Hijau = new Hijau;  
var kuning:Kuning = new Kuning;  
var array:Array = [merah, kuning, hijau];  
var timer:Timer = new Timer(3000, 9);  
var count:Number = 1;  
var border:Border = new Border;

addChild (txt\_score);  
txt\_score. text = “0”;  
txt\_score. height = 20;  
txt\_score. border = true;  
txt\_score. y=20;  
txt\_score. x=450;

addChild(border);  
border.x = 150;  
border.y = 38.5;

timer.addEventListener(TimerEvent.TIMER, trafficControl);  
function trafficControl(event:TimerEvent):void  
{  
if (count == 4)  
{  
count = 1;  
}

```
switch (count) 
{ 
    case 1: 
        merah.visible= true; 
		addChild(merah);
		merah.x = 116.5;
		merah.y = 43.5;
		kuning.visible = false; 
        hijau.visible = false; 
        break; 
    case 2: 
        merah.visible = false; 
        kuning.visible = true; 
		addChild(kuning);
		kuning.x = 176.5;
		kuning.y = 43.5;
        hijau.visible = false; 
        break; 
    case 3: 
        merah.visible = false; 
        kuning.visible = false; 
        hijau.visible = true; 
		addChild(hijau);
		hijau.x = 236.5;
		hijau.y = 43.5;
        break; 
} 
 
count++; 

```

}

timer.start();

gas.addEventListener(MouseEvent.CLICK, jalan, false, 0, true);  
function jalan(event:MouseEvent):void  
{

```
hijau.visible = false;
kuning.visible = false;
merah.visible = false;

if (count == 4){
txt_score. text = String (++num_count);
} else if (count == 3){

} else if (count == 2){

```

}

}  
rem.addEventListener(MouseEvent.CLICK, mandek, false, 0, true);  
function mandek(event:MouseEvent):void  
{  
if (count == 2){  
txt\_score. text = String (++num\_count);  
} else if (count == 4){

```
} else if (count == 3){

}
merah.visible = false;
kuning.visible = false;
hijau.visible = false;

```

}

kopling.addEventListener(MouseEvent.CLICK, setengah, false, 0, true);  
function setengah(event:MouseEvent):void  
{  
kuning.visible = false;  
hijau.visible = false;  
merah.visible = false;

```
if (count == 3){
txt_score. text = String (++num_count);
} else if (count == 4){

} else if (count == 2){

```

}

}

help please…
