Take a look at this, basically the closest thing to what you're referring to in 
Java. http://www.osflash.org/sexie
 
 
Farid

----- Original Message ----
From: Kamyar Nazeri <[EMAIL PROTECTED]>
To: Flashcoders mailing list <flashcoders@chattyfig.figleaf.com>
Sent: Monday, January 30, 2006 12:48:04 PM
Subject: Re: [Flashcoders] Dynamic class creation-thoughts?


I looked into Java Virtual Machine "Class" code, it's not possible to load a 
class dynamically in flash. at least you need to have somehow the main package 
loaded in flash!

after all it is ActionScript and it still needs lots of improvements in 
language syntax


Kamyar Nazeri <[EMAIL PROTECTED]> wrote: first, what you guys have done is 
dynamically refrencing a *loaded* class not dynamically creating a class! if 
the class is not yet loaded it returns null.

and of course dynamically refrencing a class gives you nothing, I was wondering 
if it is possible to load a class dynamically?

in Java there's a forName method on "Class" class that loads a class with given 
string and that's what we use with applications with dozens of classes, because 
it can take a long time for a big  application to load all classes 
automatically, frustrating the user. so we can give users of our program the  
illusion of a faster start with the this trick: the class  containing the main 
method does not explicitly refer to other classes. first display a splash 
screen. Then manually force the loading of other classes  by calling 
Class.forName

anybody? any suggestions for loading a class dynamically?

[EMAIL PROTECTED] wrote: 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
> {
>  variable = variable[arr[i]];
>  trace(variable);
> }
> new variable();
>
>
>
> On 1/30/06, Serge  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  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



   
---------------------------------
Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and 
used cars.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



        
---------------------------------

What are the most popular cars? Find out at Yahoo! Autos 
_______________________________________________
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