View Full Version : create checkboxes dynamically
veiky
05-31-2006, 06:52 AM
HI,
I am trying to create checkboxes dynamically.
I want the checkboxes one below the other, how can i do this?
I have tried this.. but it comes at the same position.
import mx.controls.CheckBox;
for(var i:Number=0; i<=5; i++);
{
createClassObject(CheckBox, "cb", i+20, {label:"Check Me"+i});
}
Thanks...
alissa
05-31-2006, 06:58 AM
Try this. Have a play with value of height_num depending on how far apart you want them to be:
import mx.controls.CheckBox;
var height_num:Number = 25;
for(var i:Number=0; i<=5; i++);
{
createClassObject(CheckBox, "cb", i+20, {label:"Check Me"+i, _x: 0, _y: (i * height_num)});
}
veiky
05-31-2006, 07:33 AM
Thanks Alissa,
But I think all the check boxes are coming at same position.
I can see only one check box.
Any solution?
alissa
05-31-2006, 08:24 AM
Apologies, I just copied and modified your code without actually looking at it properly.
2 things for you to do:
for(var i:Number=0; i<=5; i++); //remove the ; from the end of this line
for(var i:Number=0; i<=5; i++) //should be like this
createClassObject(CheckBox, "cb", i+20, {label:"Check Me"+i, _x: 0, _y: (i * height_num)}); //give each instance of the object a unique instance name
createClassObject(CheckBox, "cb" + i, i+20, {label:"Check Me"+i, _x: 0, _y: (i * height_num)}); //like this
veiky
05-31-2006, 08:55 AM
import mx.controls.CheckBox;
var height_num:Number = 25;
for(var i:Number=0; i<=5; i++)
{
createClassObject(CheckBox, "cb" + i, i+20, {label:"Check Me"+i, _x: 0, _y: (i * height_num)}); //like this
}
This worked.....
Thanks...
|
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.