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 [email protected], "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: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Amy
> Sent: Thursday, July 24, 2008 7:36 AM
> To: [email protected]
> Subject: [flexcoders] Re: new Component() ?
>
>
>
> --- In [email protected] <mailto:flexcoders%40yahoogroups.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
>