1 Reply Latest reply on Jul 23, 2009 9:58 AM by Flex harUI

    using dictionary (the class)

    released87 Level 1

      Hi,

       

      I am trying to create an array of 10 line item inputs. I need my client to be able to add up to 10 orders at a time with sku#, quantity and price fields. I do not want to create these manually, but dynamically with AS3. I have never used the Dictionary Class before, but I am thinking it may be helpful in this situation.

       

      private

       

       

      var items:Dictionary= new Dictionary();

       

       

      private function initPage():void {

           //Create 'container'

       

           var container:HBox= new HBox();

       

           var input_number:TextInput= new TextInput();

       

           var input_quantity:NumericStepper= new NumericStepper();

       

           var input_price:TextInput= new TextInput();

           container.addChild(input_number);

           container.addChild(input_quantity);

           container.addChild(input_price);

       

           //Add container to 'items'

       

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

                items.addItem(container);

                //Add to mx:Box 'box_items'

                box_items.addChild(items[i]);

           }    

      }

       

      This is my idea of how I can render these items on the page, though I am obviously wrong because it does not work. I basically have an HBox with 3 children, and trying to add that complex object to the Dictionary so it is indexed. That way if I want to access the value of the 3rd item_number text field I could use something like:

       

      items[2].container.input_number.text

       

      Am I on the right track? What am I missing?

       

      Thanks much,

      Jesse