0 Replies Latest reply on Sep 14, 2010 5:08 AM by fu.bian

    Timeout when implemented Flowbox

    fu.bian

      hi everyone,

      i met a problem when implemented the Flowbox,i created more than one flowbox instance on the stage then used code to add child into them dynamicly.but it blocked throwing timeout error.
      i did a simple demo to reproduce it,please see the code as below :
      
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                          layout="absolute"
                          xmlns:local="*">
           <local:FlowBox id="box1"
                             x="10"
                             y="188"
                             width="226"
                             height="133"
                             borderStyle="solid"
                             borderColor="#E36410"
                             borderThickness="2"/>
           <local:FlowBox id="box2"
                             x="290"
                             y="188"
                             width="223"
                             height="138"
                             borderStyle="solid"
                             borderColor="#37E015"
                             borderThickness="2"/>
           <local:FlowBox id="box3"
                             x="562"
                             y="188"
                             width="194"
                             height="133"
                             borderStyle="solid"
                             borderColor="#179EFC"
                             borderThickness="2"/>
           <mx:Button click="add()"
                        x="290"
                        y="77"
                        label="add"/>
           <mx:HSlider minimum="1"
                          maximum="100"
                          id="sl"
                          liveDragging="true"
                          x="353"
                          y="128"
                          snapInterval="1"
                          value="1"/>
           <mx:Script>
                <![CDATA[
                     import mx.collections.ArrayCollection;
                     import mx.containers.BoxDirection;
                     import mx.controls.Label;
      
                     private function add():void
                     {
                          var arr:ArrayCollection=new ArrayCollection();
                          for (var i:int=0; i < sl.value; i++)
                          {
                               var s:String=String(Math.random().toFixed(int(Math.random() * 10)));
                               var lbl:Label=new Label();
                               lbl.text=s;
                               box1.addChild(lbl);
      
                          }
                          for (var i:int=0; i < sl.value; i++)
                          {
                               var s:String=String(Math.random().toFixed(int(Math.random() * 10)));
                               var lbl:Label=new Label();
                               lbl.text=s;
                               box2.addChild(lbl);
      
                          }
                          for (var i:int=0; i < sl.value; i++)
                          {
                               var s:String=String(Math.random().toFixed(int(Math.random() * 10)));
                               var lbl:Label=new Label();
                               lbl.text=s;
                               box3.addChild(lbl);
      
                          }
      
                     }
                ]]>
           </mx:Script>
           <mx:Label x="255"
                       y="128"
                       text="element count:"/>
      
      </mx:Application>
      
      
      Thanks very much