Skip to main content
Participant
June 29, 2009
Question

Dynamic fields as3

  • June 29, 2009
  • 1 reply
  • 319 views

Hi for the code below i have to always have an if for the items (if i==2) if (i==3) and then also create different textfields..sometimes though i might have more than 10 items in this case i have to do the same thing over and over again....
hwo can i change this code so tas long as we are in the loop i am getting dynamically textfields created and i dont have to use if and manucall create the,

for each (var captionElement:XML in categorylist)  
        {  
            i++;
            //gia ta categor
            if (a == 1){
            if (i == 1)
            {
                InstanceName_5.text = captionElement.attribute("name");
                butext.text = captionElement.attribute("name");
                myF._targetInstanceName = "InstanceName_5";
                myF.showDelay = 0;
                myF.showAutoPlay = true;
                myF.hideDelay = 7;
                myF.hideAutoPlay = true;
                trace (captionElement.attribute("name")); 
            }
              var itemslist:XMLList = captionElement.item;
            for each (var captionElement:XML in itemslist)  
            {  
                   // gia ta items
                InstanceName_6.text = InstanceName_6.text + captionElement;
                my6._targetInstanceName = "InstanceName_6";
                my6.showDelay = 8;
                my6.showAutoPlay = true;
                my6.hideDelay = 7;
                my6.hideAutoPlay = true;
                trace(captionElement);
            } } 
           
            if (a == 2){
            if (i == 2)
            {
                InstanceName_5.text = captionElement.attribute("name");
                myF._targetInstanceName = "InstanceName_5";
                myF.showDelay = 0;
                myF.showAutoPlay = true;
                myF.hideDelay = 7;
                myF.hideAutoPlay = true;
                trace (captionElement.attribute("name")); 
            }
              var itemslist:XMLList = captionElement.item;
            for each (var captionElement:XML in itemslist)  
            {  
                   // gia ta items
                InstanceName_6.text = InstanceName_6.text + captionElement;
                my6._targetInstanceName = "InstanceName_6";
                my6.showDelay = 8;
                my6.showAutoPlay = true;
                my6.hideDelay = 7;
                my6.hideAutoPlay = true;
                trace(captionElement);
            } } 
           
            if (a == 3){
            if (i == 3)
            {
                InstanceName_5.text = captionElement.attribute("name");
                myF._targetInstanceName = "InstanceName_5";
                myF.showDelay = 0;
                myF.showAutoPlay = true;
                myF.hideDelay = 7;
                myF.hideAutoPlay = true;
                trace (captionElement.attribute("name")); 
            }
              var itemslist:XMLList = captionElement.item;
            for each (var captionElement:XML in itemslist)  
            {  
                   // gia ta items
                InstanceName_6.text = InstanceName_6.text + captionElement;
                my6._targetInstanceName = "InstanceName_6";
                my6.showDelay = 8;
                my6.showAutoPlay = true;
                my6.hideDelay = 7;
                my6.hideAutoPlay = true;
                trace(captionElement);
            } } 
   

Many Thanks

Ivan

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 29, 2009

those all look the same:


for each (var captionElement:XML in categorylist)  
        {  
            i++;
            //gia ta categor
            if (a == i){
            {
                InstanceName_5.text = captionElement.attribute("name");
                butext.text = captionElement.attribute("name");
                myF._targetInstanceName = "InstanceName_5";
                myF.showDelay = 0;
                myF.showAutoPlay = true;
                myF.hideDelay = 7;
                myF.hideAutoPlay = true;
                trace (captionElement.attribute("name")); 
            }
              var itemslist:XMLList = captionElement.item;
            for each (var captionElement:XML in itemslist)  
            {  
                   // gia ta items
                InstanceName_6.text = InstanceName_6.text + captionElement;
                my6._targetInstanceName = "InstanceName_6";
                my6.showDelay = 8;
                my6.showAutoPlay = true;
                my6.hideDelay = 7;
                my6.hideAutoPlay = true;
                trace(captionElement);
            } } 
          }