Hi there,

I am trying to create a factory component that will instantiate other
components based on the data loaded from the server. I know how to do
it for non visual classes/objects, but for visual components it's not
very clear for me what path should I follow.

Having a "factory component" like this:

<container id="containerComp">
  <factoryComponent id="factoryComp" width="400" height="300"
label="some label" click="clickHandler()"/>
</container>

I would like to be able to say something like this (pseudo AS3 code):

private function onDataLoaded(e:Event) {
  // this should both instantiate a new component derived from
CompBase and initialize it with factoryComp's properties (defined in MXML)
  var cb:CompBase = factoryComp.create(e.result.compType);
  
  containerComp.removeChild(factoryComp);
  containerComp.addChild(cb);
}

I tried actually implementing the above code but it does not work. I'm
getting a ton of runtime errors...

I also looked into deferred instantiation and IFactory/ClassFactory
but the help is scarce on these topics. Some code samples would really
help there.

Has anybody tried something similar? Any ideas on how to do this?

TIA,
Alex




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcomponents/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcomponents/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to