Hi David,

you need to initialize the tab Array inside a function. For example
inside your Box-subclass component do something like this

<mx:Box initialize="initArray()" ...>
  <mx:Script>
    var tab:Array;

    private function initArray():Void {
        // fill you Array here
      tab = [abc, def, ...]
    }

  </mx:Script>
</mx:Box

This will create the Array as soon as your Box-subclass gets created. 

Dirk.


-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of ROUSSELIE David ROSI/SIFAC
Sent: Wednesday, July 13, 2005 11:54 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] create Children dynamically

Hello, 

I would like to create children in my container (inherited from Box). I
have this code :
<mx:Script>
        var tab : Array = [mypkg.myobj, mypkg.myobj, ...]; </mx:Script>

...

        <mycontainer dataProvider="{tab}" ... />

and in mycontainer.as :

...

for (var i = 0; i < dataProvider.length; i++)
        createChild(dataProvider[i], "myobj" + String(i), {});

...

until now all was good, but when I want to add an object not in a
package (like above myobj in mypkg) I got this error :

"A class's instance variables may only be initialized to compile-time
constant expressions."

with tab = [myobj_nopkg];

and with objects from mxml files I cannot put them in packages :
for example, in file myobj_nopkg.mxml :
<mx:Panel ...>
...
</mx:Panel>

So two solutions :
        - declare a mxml file in a package : How ?
        - resolve error above : How ?

Thanks,

--
David Rousselie


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to