Nice job for creating dynamic linked library in flash, thanks to Farid and Scott. Of course compiled clips and components do the same, but using dlls gives us the ability to load classed whenever they are needed and not just including them all in the first frame! I was wondering if it is possible to load a class with a given string using pure ActionScript and I guess it's not. Well that's not an issue in flash and I was wrong to compare Java and flash in this case because in Java classes are compiled in separate .java files and it takes time for an application to load them all at startup, hence manually loading classes (as I described in my other post) can improve application performance, but since in flash all classes are embedded in a single compiled .swf file they are available when swf is loaded
Kamy Scott Hyndman <[EMAIL PROTECTED]> wrote: Hey Kamyar, Sure it is...unless I misunderstand you. http://www.osflash.org/using_a_swf_as_a_dll Scott -----Original Message----- From: [EMAIL PROTECTED] on behalf of Kamyar Nazeri Sent: Mon 1/30/2006 12:48 PM To: Flashcoders mailing list Cc: 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 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 --------------------------------- Do you Yahoo!? With a free 1 GB, there's more in store with Yahoo! Mail. _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders