I have a combobox on my main when I select a supplier I want the Supplier Component to Run its init() with the new supplier number. I cannot figure out how the componet knows when/how to fire the init() that would fire of my RO with the new SupplierID.
My main has a combobox and this local, to bring in the component:
<local:SupplierContent/>
So change the Combobox and the above would reload with the new supplier number. The RO and init() are all in the SupplierContent.
Any thoughts?
Thanks
George
in the change handler of your combobox you can create new instance of SupplierContent with the new selected supplier number.
private function changeHandler():void{
var supplierContentObj:SupplierContent = new SupplierContent();
this.addChild(supplierContentObj)
}
I like what you are showing me. I apply the code you shared with me and it adds another instance of the of the component. If I select another it adds another. How do I get rid of the old component. Also I do not see how this triggers the init() in the component?
Thanks
George
private function changeHandler():void{
if(supplierContentObj){
this.removeChild(supplierContentObj);
supplierContentObj = null;
}
var supplierContentObj:SupplierContent = new SupplierContent();
this.addChild(supplierContentObj);
}
Whenever a new instance of a component is created, the creationComplete event is dispatched. So, assuming that init() is the creationComplete eventHandler, this will also be called on every new instance creation.
Simple...
private function comboChangehandler():void
{
this.addChild(s1)
s1.init();
}
<local:SupplierContent id ="s1"/>
thats it...
Copyright © 2011 Adobe Systems Incorporated. All rights reserved.
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).