So i am making bejeweled in AS3 right now and it is not going well at all. So far i placed the gem randomly by using a array but it doesnt check for a 3 in a row and if there is a 3 in a row, the 3 gems do not disappear. the coding i have so far is this:

var RandomArray = new Array(pic1, pic2, pic3, pic4, pic5, pic6, pic7, pic8, pic9, pic10, pic11, pic12, pic13, pic14, pic15, pic16, pic17, pic18, pic19, pic20, pic21, pic22, pic23, pic24, pic25, pic26, pic27, pic28, pic29, pic30, pic31, pic32, pic33, pic34, pic35, pic36);

var DiamondSprite:Sprite; var Diamond:diamond;

var OrangeSprite:Sprite; var Orangerange;

var RedSprite:Sprite; var Red:red;

var WhiteSprite:Sprite; var White:white;

var YellowSprite:Sprite; var Yellow:yellow;

for(var i:int=0; i<36; i++){

var RandomGem = Math.floor(Math.random()*125);

if(RandomGem <= 25){

DiamondSprite = new Sprite(); this.addChild(DiamondSprite); Diamond = new diamond(); DiamondSprite.addChild(Diamond); DiamondSprite.scaleX = DiamondSprite.scaleY = .5;

DiamondSprite.x = RandomArray[i].x; DiamondSprite.y = RandomArray[i].y; }

else if(RandomGem <= 50 && RandomGem > 25){

OrangeSprite = new Sprite(); this.addChild(OrangeSprite); Orange = new orange(); OrangeSprite.addChild(Orange); OrangeSprite.scaleX = OrangeSprite.scaleY = .5; OrangeSprite.x = RandomArray[i].x; OrangeSprite.y = RandomArray[i].y; } else if(RandomGem <= 75 && RandomGem > 50){

RedSprite = new Sprite(); this.addChild(RedSprite); Red = new red(); RedSprite.addChild(Red); RedSprite.scaleX = RedSprite.scaleY = .5;

RedSprite.x = RandomArray[i].x; RedSprite.y = RandomArray[i].y; } else if(RandomGem <= 100 && RandomGem > 75){

WhiteSprite = new Sprite(); this.addChild(WhiteSprite); White = new white(); WhiteSprite.addChild(White); WhiteSprite.scaleX = WhiteSprite.scaleY = .5;

WhiteSprite.x = RandomArray[i].x; WhiteSprite.y = RandomArray[i].y; } else if(RandomGem <= 125 && RandomGem > 100){

YellowSprite = new Sprite(); this.addChild(YellowSprite); Yellow = new yellow(); YellowSprite.addChild(Yellow); YellowSprite.scaleX = YellowSprite.scaleY = .5;

YellowSprite.x = RandomArray[i].x; YellowSprite.y = RandomArray[i].y; }

}

What I neeed help with is finding a three in a row in the randomly placed gems (by using an array), able to swap a gem to make a three in a row, when you made a 3 in a row.. the 3 gems disappear and more gems fall down.. if you played bejeweled before, you will understand what im talking about. Also I want to make the explosive gem which is when you get a 4 in a row, it makes a explosive gem and when you match the explosive gem, it wipes out like few gems surround it. someone please help me!! D: