If your renderers are all in a library, they all get included AFAIK. So separate them out and use compc rather than mxmlc to generate the swf for them.
Gk. Gregor Kiddie Senior Developer INPS Tel: 01382 564343 Registered address: The Bread Factory, 1a Broughton Street, London SW8 3QJ Registered Number: 1788577 Registered in the UK Visit our Internet Web site at www.inps.co.uk <blocked::http://www.inps.co.uk/> The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of INPS or any of its affiliates. If you are not the intended recipient please contact [email protected] ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of jimmy5804 Sent: 22 March 2009 07:24 To: [email protected] Subject: [flexcoders] Architecting for extensibility I'm looking for some architecture advise. My AIR application has the ability to render certain kinds of data, each of which has a unique string descriptor (e.g. "red"). I would like to make it easy for others to add renderers for other kinds of data. To accomplish this, I created a renderer directory (Object) where the data descriptor is a key to the class path for the renderer and I planned to make extensive use of dynamic instantiation - when I ran into "red" data, I could just look up the "red" renderer, instantiate it, etc. My thinking was that the new developer would just need to create a renderer that implemented the requiste interface, create an entry in the directory, and would need very minimal understanding of the rest of the architecture to get their data to render. But I ran into the problem described here: http://thillerson.wordpress.com/2007/03/01/runtime-class-instantiation-i n-actionscript-30/ <http://thillerson.wordpress.com/2007/03/01/runtime-class-instantiation- in-actionscript-30/%20> If you don't want to read it all, basically you need to make sure the referenced class has been loaded into your swf before you try to reference it (at least, that's my understanding). So, in my directory, I created something that creates and then destroys (for memory conservation) an instance of each renderer, and now my directory looks something like this: public class RendererDirectory { private var dir:Object { red:"com.blah.renderers.MyRenderer", blue:"com.joedata.renderers.BlueRenderer", ...}; // to make sure everything is in .swf private static function kluge():void { var a:Array = [new MyRenderer(), new BlueRenderer(), ...]; a = null; } public function getRenderer(datakey:String):IMyInterface { // all error checking omitted for brevity var classPath:String = dir[datakey]; var classRef:Class = getDefinitionByName(classPath) as Class; return new classRef(); } } I'm looking for advise on whether there is a better way to accomplish my big picture goal (ease of extensibility) or improve on my current scheme in some way. TIA!

