Pedro Kostelec wrote:

Thanks, but there is still the other error
1120: Access of undefined property letters.
var randomIndex:uint=Math.floor(Math.random()*letters.length);

This code works for me:

var letters:Array= ["A","B","C","D","E","F",
  "G","H","I","J","K","L",
  "M","N","O","P","Q","R",
  "S","T","U","V","W",
  "X","Y","Z",];

function getRandomLetter():String {
   var randomIndex:uint=Math.floor(Math.random()*letters.length);
   return letters[randomIndex];
}

import fl.controls.Button;

var i:uint=0;
var j:uint=0;
var posX:uint=0;
var posY:uint=0;
var buttonSize:uint=25;

while(posY<stage.stageHeight){
   posX=0;
   j=0;
   posY=i * buttonSize;

   while(posX<stage.stageWidth){
       posX= j * buttonSize;
       var b:Button= new Button
       b.setSize(buttonSize,buttonSize);
       b.move(posX, posY);
       b.label=getRandomLetter();
       addChild(b);
       j++;
   }
   i++;
}

Cheers,
Claus.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to