Controlling properties on items added to the stage in a loop


hi there,

 

i have loop adds xml elements stage (10). once added, need control items (checkbox = something).

 

here add them stage.

          private function createlayout():void {                container = new vbox();                                for(var i:int=0; i<10; i++) {                     vbox = new vbox();                     hbox = new hbox();                     titletext = new linkbutton();                     iteminfo = new text();                     abstract = new text();                     archive = new checkbox();                     rateitem = new combobox();                     category = new combobox();                     var categorylabels:array = new array("food & ag","news","health","people","general","what's coming","biofuel","environment");                     var ratelabels:array = new array("excellent","good","bad","neutral","controversial");                      titletext.label = listcollection.getitemat(i).title;                     titletext.width = 400;                     iteminfo.text = listcollection.getitemat(i).source + " | " + listcollection.getitemat(i).date;                     abstract.text = listcollection.getitemat(i).abstract;                     abstract.width = 400;                     archive.label = "archive";                                          category.prompt = "category";                     category.dataprovider = categorylabels;                     category.rowcount = categorylabels.length;                      rateitem.prompt = "rate";                     rateitem.dataprovider = ratelabels;                                          vbox.addchild(titletext);                     vbox.addchild(iteminfo);                     vbox.addchild(abstract);                     vbox.addchild(hbox);                                          hbox.addchild(archive);                          hbox.percentwidth = 80;                     hbox.percentheight = 80;                     archive.addeventlistener(event.change, togglearchive);                                                              container.addchild(vbox);                }                                addchild(container);            } 

 

i listen checkbox (change event) , when clicked, call function adds 2 comboboxes stage.

 

archive.addeventlistener(event.change, togglearchive);     

 

i call function handle event.

 

          public function togglearchive(e:event):void {                if(archive.selected == true){                     hbox.addchild(category);                     hbox.addchild(rateitem);                                    }                else {                     hbox.removechild(category);                     hbox.removechild(rateitem);                }           } 

 

 

 

when have 1 item works fine.

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

 

when add 10 nothing happens. feel should doing identify item i'm referring to. thoughts/reccomendations br great!

give category , rateitem objects names, category.name = "category";

 

then don't add remove based on combobox, set these properties:

 

var cb:combobox = mytopvbox.getchildat(i).getchildbyname(category);

cb.visible = false;

cb.includeinlayout = false;



More discussions in Flex (Read Only)


adobe

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???