For further understanding... am putting down my code...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; name="container"
layout="absolute" creationComplete="init()">

   <mx:Script>
       <![CDATA[

        private var grid:Grid = null;
           private var gridRow:GridRow = null;
           private var gridItem:GridItem = null;

        private var vbox:VBox = null;

        private var label:Label = null;

        public function init():void{
               grid = new Grid();

            gridRow = new GridRow();

            for(var i:int = 0; i < 4; i++){
                gridItem = new GridItem();

                addImage = new Image();
                addImage.id = i;
                addImage.source = "assets/add.png";
                addImage.addEventListener(
                    MouseEvent.CLICK,addImageClicked

                );

                vbox = new VBox();
                vbox.name = "GB_"+i;
                vbox.addChild(addImage);

                gridItem.addChild(vbox);
            }

            gridRow.addChild(gridItem);

            grid.addChild(gridRow);

            gridPanel.addChild(grid);
        }

        function addImageClicked(event:MouseEvent):void{
            label = new Label();
            label.text = "Child Added";

            var id = event.currentTarget.id;

            var target:VBox = grid.getChildByName("GB_"+id) as VBox;

            Alert.show("Target Object :: "+target);

            target.addChild(label);
           }

    ]]>
   </mx:Script>

   <mx:Panel title="Grid Container Example" height="75%" width="75%" id="*
gridPanel*">
   </mx:Panel>
</mx:Application>

As marked in yellow, I am creating a Grid Object, GridRow, GridItem... Later
creating a VBox object, in which am adding an image with id as i and the
VBox is names as "GB_"+i , where i is the for loop index.

Added eventListener on the image object, which when clicked shall invoke
addImageClicked().

In that function, i need to create a Label object, assign the text and add
to the Vbox object in the GridItem which has been names as "GB_"+i .

So if i click on Image with ID = 2, than i need to get the VBox with name as
" GB_2 ", and add a Label child to that VBox.

So am concerned about getting the VBox object which is named as " GB_2 ".

Tried with getChildByName() , but receiving the object as null.

Please help me over this.

Thanks,
Madan N

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to