Hi Guys (and Girls),

Ok, so I have been fighting a couple of days to figure this out. 

In order to make a large and compliated form with drag and drop in of 
more form fields I want to dynamically add an id to an display 
object, and then be able to reference it later to get data out.

Somehow it only seems possible to find these objects by navigating 
trough the the displaylist, and I cannot assign any 'real' id to a 
newly created child.

The following example should illustrate what I want to do (it should 
run). You will find it quite imposssible to get the object by it's id 
(or uid). 

Why is that?? Is there any other way of referencing an object of 
which you do not know who his parent is?


Thank you in advance and greetings,
Thatcher



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="vertical">

<mx:Script>
<![CDATA[
        import mx.controls.Text;
        
        private function addMyChild():void {
                var myChild:Text = new Text();
                myChild.text = "Hello World!!";
                myChild.id = "kid1";
                myChild.name = "kid1";
                myChild.uid = "kid1";
                myPanel.addChild(myChild);
        }

        private function getMyChildById():void {
                var childReference:Text = this["kid1"] as Text;
                trace (childReference);
        }
        
        private function getMyChildByName():void {
                var childReference:Text = myPanel.getChildByName
("kid1") as Text;
                trace (childReference);
        }

]]>
</mx:Script>

<mx:Button label="add my child" click="addMyChild()" />

<mx:Panel id="myPanel"></mx:Panel>

<mx:Button label="get my child by id" click="getMyChildById()" />
<mx:Button label="get my child by name" click="getMyChildByName()" />


</mx:Application>


Reply via email to