# Creating A Random Card Deck

**URL:** <https://forum.kirupa.com/t/creating-a-random-card-deck/300371>\
**Category:** flash\
**Created:** [November 19, 2009, 10:00pm UTC](https://forum.kirupa.com/t/creating-a-random-card-deck/300371 "2009-11-19T22:00:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArdorEdor](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ArdorEdor](https://forum.kirupa.com/u/ArdorEdor)\
**Post date:** [November 19, 2009, 10:00pm UTC](https://forum.kirupa.com/t/creating-a-random-card-deck/300371/1 "2009-11-19T22:00:37Z")

</div>

Hello…

I’m trying to add a second card deck to this matching game, but can’t wrap my head around how to set up a second random feature to call one of three arrays.

My problem is that I want to call 6 cards each time I start a new game, but for the sake of not boring people with the imagery, I want to have it so that the card types vary each time they start a new game, meaning flash calls one of three decks. What I’ve come up with so far is below… and I included the as file… Any help would be greatly appreciated! New to game programming…

```
 var colordeck:Array = new Array(1,1,2,2,3,3,4,4,5,5,6,6);
 var colordeck2:Array = new Array(7,7,8,8,10,10,11,11,12,12,13,13);
 var colordeck2:Array = new Array(14,14,15,15,16,16,17,17,18,18,19,19);

```

public function color\_match() {  
for (x=1; x\<=4; x++) {  
for (y=1; y\<=4; y++) {  
var random\_card = Math.floor(Math.random()\*colordeck.length);  
var tile:colors = new colors();  
tile.col = colordeck[random\_card];  
colordeck.splice(random\_card,1);  
tile.gotoAndStop(9);  
tile.x = (x-1)\*112;  
tile.y = (y-1)\*112;  
tile.addEventListener(MouseEvent.CLICK,tile\_clicked);  
addChild(tile);  
}
