Friends,

I'm aware that if all the elements are in the stage to get its object
just use its "id".

Like if i create a <mx:TextInput id="foo" /> to work with it on the
actionscript just use foo.text = 'bla' for example.

The thing is i'm creating a lot of forms dynamically and i'm
struggling myself with something that it is keeping me awake for
almost a week.

i wrote the following code so you guys can help me. 

So, looking at this code and suppose that you CAN NOT change not one
line of this code, how do i work with "foo" in the myTimer function? i
can't use getChildren because there is no way to know the name of the
last canvas. if i trace foo on the runtime of the script i would get
something like
test0.myCanvas.Canvas7.Canvas8.Canvas9.Canvas10.Canvas11.Canvas12.Canvas13.Canvas14.Canvas15.Canvas16.testing
and that's exactly what i want, BUT i need to get it inside the
myTimer function, what means later after it creates the textinput. In
old times on flash i would just use _root['foo'] and it would work, no
headaches =/

So how could i solve that? why flex don't just let me use "foo.text =
'bla'"  like it would be in the stage?

please, someone enlight me because i'm really getting a headache with
this #*#*#@ =/ 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="init()">
<mx:Script>
        <![CDATA[
                import mx.controls.TextInput;
        function init() 
        {
                var last:Canvas = myCanvas;
                for (var i:Number =0;i<10;i++)
                {
                        var cc:Canvas = new Canvas();
                        last.addChild(cc);
                        last = cc;
                }
                
                var foo:TextInput = new TextInput();
                foo.id = "test";
                foo.name = "testing";
                last.addChild(foo);
                
                //trace(foo); // trace something like
test0.myCanvas.Canvas7.Canvas8.Canvas9.Canvas10.Canvas11.Canvas12.Canvas13.Canvas14.Canvas15.Canvas16.testing
                
                
                var dialogTimer:Timer = new Timer(2000,1);
                dialogTimer.addEventListener("timer", myTimer); 
                dialogTimer.start();
        }
                                                
                                                
        function myTimer(event:TimerEvent):void 
        {
                // i need to work with the object "foo"
                // do for example something like foo.text = 'test'              
        }
        ]]>
</mx:Script>
    <mx:Canvas id="myCanvas" />


</mx:Application>


Reply via email to