/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private function generateBoard(startX:Number,startY:Number,totalRows:Number,totalCols:Number,buttonSize:Number):void { buttons = new Array(); var colCounter:uint; var rowCounter:uint; for(rowCounter = 0; rowCounter < totalRows; rowCounter++) { for(colCounter = 0; colCounter < totalCols; colCounter++) { var b:Button = new Button(); b.x = startX + (colCounter*buttonSize); b.y = startY + (rowCounter*buttonSize); b.addEventListener(MouseEvent.CLICK, letterClicked); b.label = getRandomLetter().toUpperCase(); b.setSize(buttonSize,buttonSize); b.name = "buttonRow"+rowCounter+"Col"+colCounter; addChild(b); buttons.push(b); } } }