Just a general, - what are people's thoughts on dynamic class
instantiation? I've always been under the impression( and hence, been
told) that one should avoid it at all costs.

Thoughts? Discussion? Benefits? Would it be better to implement a factory
type pattern to create the new instances of classes?

> thank you all, i've already made it!
>
> var str:String = 'test1.test2.ClassC';
> var arr = str.split('.');
> var variable = _global;
>
> for (var i=0;i<arr.length;i++)
> {
>       variable = variable[arr[i]];
>       trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge <[EMAIL PROTECTED]> wrote:
>>
>>  import pkg1.pkg2.pkg3.*
>> or
>> import pkg1.*
>>
>>  >> new pkg1.pkg2.pkg3.className(),
>> sorry, should be:
>> new className()
>>
>>  make sure pkg1 has classes you would like to be compiled in swf or
>> use exclude xml file
>>
>>
>>
>> On 1/30/06, franto <[EMAIL PROTECTED]> wrote:
>> >> Hi all,
>> >>
>> >> maybe it is easy, maybe not, but i cant figure it out now, and i
>> need it :)
>> >>
>> >> when i got class e,g    pkg1.pkg2.pkg3.className
>> >>
>> >> i can make new instance in this way
>> >> new pkg1.pkg2.pkg3.className()
>> >>
>> >> but i want to make it from string
>> >>
>> >> this dont work of course
>> >> _global['pkg1.pkg2.pkg3.className']();
>> >>
>> >> but this work:
>> >> _global['pkg1']['pkg2']['pkg3']['className']();
>> >>
>> >> can this done automatcally? i want jsut read string from XML and
>> create new class instance,
>> >> but i cant do it now.
>> >> Any help is appreciated :)
>> >>
>> >> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>> Franto
>> >>
>> >> http://blog.franto.com
>> >> http://www.flashcoders.sk
>> >> _______________________________________________
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > _______________________________________________
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> > _______________________________________________
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> _______________________________________________
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
> --
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
> Franto
>
> http://blog.franto.com
> http://www.flashcoders.sk
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to