hi all
i've been trying while it's not working... think it's because flash has way of declaring arrays don't get... looked around, managed find examples missing because results negative...
i want simple 3x4 grid of objects loaded library... code this
public class broadcast extends sprite
{
var cols:number = 3;
var rows:number = 4;
var i:number;
var j:number;
var size:number = 10;
public function broadcast():void
{
if (stage)
{
init();
}
else
{
addeventlistener(event.added_to_stage, init);
}
}
private function init(e:event = null):void
{
removeeventlistener(event.added_to_stage, init);
var mainarr:array = new array(cols);
(i = 0; < cols; i++)
{
mainarr[i] = new array(rows);
trace (mainarr); //just feedback
(j = 0; j < cols; j++)
{
mainarr[i][j] = new checkbox(this,j*size,j*size,"",onbtnclick);
}
}
so 3 checkbox objs each traslated of 10(size); diagonal line of obj, instead of grid; suspect obj created 1 on top of other, 1 unique line...
any idea show others too?
the reason 3 showing versus 4 because using "cols" both loops rather thah cols , rows.
why getting diagonal escapes me, have suspiscions around doing checkbox() instantiation. far can tell, checkbox constructor not take arguments, cannot see how without errors. still, assuming do, purpose of using j*size twice way do? suspect need " " invloved in there.
More discussions in ActionScript 3
adobe
Comments
Post a Comment