[flexcoders] Why are icons typed as Classes and not just class factories?
One of the beauties of Flash's display list API is the ability to treat almost all visual elements as the universal DisplayObject and not be concerned with whether they're a simple shape or whether they're a complex, multi-state movie clip. But, when it comes to Flex framework widgets, like buttons, trees, etc., when an icon is referenced Flex expects a Class. Now, I understand that this is done because (a) it gives you a factory and (b) it makes CSS handling easier. But those don't seem like good trade-offs considering the incredible limitation it introduces (no dynamic instances for icons, for example) and the fact that Flex already has a built-in mechanism for Factory interfaces. So, what's the reasoning? What gives? Troy.
RE: [flexcoders] Why are icons typed as Classes and not just class factories?
Factories came late to the party and we couldn't retrofit everything. One of the things we wish we could do-over. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of thirtyfivemph Sent: Wednesday, July 09, 2008 3:06 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Why are icons typed as Classes and not just class factories? One of the beauties of Flash's display list API is the ability to treat almost all visual elements as the universal DisplayObject and not be concerned with whether they're a simple shape or whether they're a complex, multi-state movie clip. But, when it comes to Flex framework widgets, like buttons, trees, etc., when an icon is referenced Flex expects a Class. Now, I understand that this is done because (a) it gives you a factory and (b) it makes CSS handling easier. But those don't seem like good trade-offs considering the incredible limitation it introduces (no dynamic instances for icons, for example) and the fact that Flex already has a built-in mechanism for Factory interfaces. So, what's the reasoning? What gives? Troy.
Re: [flexcoders] Why are icons typed as Classes and not just class factories?
Factories came late to the party and we couldn't retrofit everything. One of the things we wish we could do-over. Understood. Anyone done the dirty work of allowing dynamic classes to be created? Seems like it'd be entirely doable by generating the bytecode for a class, giving it a unique name, and de-serializing it with a ByteArray (kinda like the tricks folks employed for dynamic sounds in v9 player). Also, as a complete aside, if there a way to get the Class of an instance? I'm thinking something like this: var c:Class = ClassUtils.getClass(someVar); Troy.
Re: [flexcoders] Why are icons typed as Classes and not just class factories?
Have a look at Ben Stucki's work, it may solve your icon problems. http://blog.benstucki.net/?p=42 As far as getting a class reference from an instance, you could use getQualifiedClassName on the instance to get the name, and then pass that to getDefinitionByName to get the class On Wed, Jul 9, 2008 at 5:15 PM, Troy Gilbert [EMAIL PROTECTED] wrote: Factories came late to the party and we couldn't retrofit everything. One of the things we wish we could do-over. Understood. Anyone done the dirty work of allowing dynamic classes to be created? Seems like it'd be entirely doable by generating the bytecode for a class, giving it a unique name, and de-serializing it with a ByteArray (kinda like the tricks folks employed for dynamic sounds in v9 player). Also, as a complete aside, if there a way to get the Class of an instance? I'm thinking something like this: var c:Class = ClassUtils.getClass(someVar); Troy.