You can't really do what you want, without creating custom item renderer
components or custom IFactories. You could possibly create one base
component, and pass in a callback function as one of the parameters in
initObject for an InitFactory, but that's a terrible idea for any number of
reasons, chiefly your code will be unreadable and unmaintainable.

Honestly if you'd just tell us what and why you're actually trying to
achieve for the end user (and why you just can't use regular renderer
classes or labelfunctions) then we'd be able to give you alternatives that
make sense for your use case.

-Josh

On Fri, Jul 25, 2008 at 10:14 AM, Rafael Faria <[EMAIL PROTECTED]>
wrote:

> I found this class
>
> package modules.renderers
> {
>        import mx.core.ClassFactory;
>
>        import org.osflash.thunderbolt.Logger;
>
>        public class InitFactory extends ClassFactory
>        {
>                private var initObject:Object;
>
>                public function InitFactory(generator:Class,
> initObject:Object)
>                {
>                        super(generator);
>                        this.initObject = initObject;
>                }
>
>                public override function newInstance():*
>                {
>                        var result:* = super.newInstance();
>
>                        for(var propertyName:String in initObject)
>                        {
>                                try
>                                {
>                                        result[propertyName] =
> initObject[propertyName];
>                                }catch (e:Error)
>                                {
>                                        trace(e.message);
>                                }
>                        }
>                        return result;
>                }
>        }
> }
>
>
> and i'm able to add a new class on the fly doing
>
>
> dgc.itemRenderer = new InitFactory(TextInput, {text:'Value inside the
> text input'});
>
>
> now i'm struggling to make the textinput, to get values from the
> "data" variable coming from the dataProvider. You know, when inside
> the itemrender you can use {data.firstname + ' ' + data.lastname}
> like: <mx:TextInput text="{data.firstname + ' ' + data.lastname}" />
>
> With the example i gave above, how i would do that?
>
> Raf
>
>
>
> Any idea how i would pass this data to the checkbox label
>
>
>
>
> --- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
> >
> > You can't add to the class definition of the Canvas at runtime.
> > ClassFactory has a properties bag where you can have properties slapped
> > on the new instance, but that's not really a new class definition.
> >
> >
> >
> > ________________________________
> >
> > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> > Behalf Of Amy
> > Sent: Thursday, July 24, 2008 7:36 AM
> > To: flexcoders@yahoogroups.com
> > Subject: [flexcoders] Re: new Component() ?
> >
> >
> >
> > --- In flexcoders@yahoogroups.com 
> > <mailto:flexcoders%40yahoogroups.com<flexcoders%2540yahoogroups.com>
> >
> > , "Alex Harui" <aharui@> wrote:
> > >
> > > If you've defined a component via <mx:Component>, the name is
> > > auto-generated as Josh says, but it generates an IFactory, so you
> > can
> > > use the factory to get new instances
> > >
> > >
> > >
> > > <mx:List id="myList>
> > >
> > > <mx:itemRenderer>
> > >
> > > <mx:Component>
> > >
> > > <mx:Canvas>
> > >
> > > ..
> > >
> > >
> > >
> > >
> > >
> > > From AS:
> > >
> > >
> > >
> > > myList.itemRenderer.newInstance()
> >
> > This makes it sound like the equivalent to new Component() in AS
> > might be
> >
> > myRenderer:ClassFactory = new ClassFactory(mx.containers.Canvas);
> >
> > Presumably from there you can add stuff to myRenderer before using it
> > as your "rubber stamp", but I've never personally used ClassFactory
> > for anything other than setting global properties on a class I
> > created in AS3 or MXML.
> >
> > Is this a correct interpretation of how AS3 works?
> >
> > Thanks;
> >
> > Amy
> >
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to