Hi Animesh,
The call:
SmartyPants.getOrCreateInjectorFor(this);
Basically is a static factory, that first checks for an existing injector that would be valid, and if it can't find one, creates it. And we have
injector.injectInto(foo);
As a means of getting injection into objects that were created "behind our back" by the Flex SDK, or by the our application by way of the MXML -> ActionScript translation.
You don't need to do it on every MXML component, in fact depending on what you're trying to do, you don't necessarily need to do it at all. Any objects that are created by the injector will automatically be injected into, but when you're instantiating components via MXML declarations, the creation happens with a bunch of "new" statements and SmartypPants doesn't know about them. We do have an MXML tag for convenience when you want to inject into objects that are instantiated via MXML:
<smartypants:RequestInjection/>
This will simply listen for CreationComplete on the parent component, and make the calls to get the injector and perform the injection. I'm also working at the moment on a slight simplification of the API, and I'm considering a feature that will allow you to schedule this to happen automatically on all newly created components.
Cheers,
-Josh
--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."
Josh 'G-Funk' McDonald
-
jo...@joshmcdonald.info
-
http://twitter.com/sophistifunk -
http://flex.joshmcdonald.info/