Quick and dirty... [ MyApplication.mxml ] <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:ns1="*"> <mx:VBox x="10" y="10"> <ns1:CustomComponent/> </mx:VBox> </mx:Application>
[ CustomComponent.mxml ] <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import mx.core.Application; private function createNewCustomComponent():void { var newCustomComponent:CustomComponent = new CustomComponent(); Application.application.addChild(newCustomComponent); } ]]> </mx:Script> <mx:HBox x="10" y="10"> <mx:Button id="myButton" label="Create New" click="createNewCustomComponent()"/> <mx:Label text="CustomComponent"/> </mx:HBox> </mx:Canvas> HTH Steve --- In flexcoders@yahoogroups.com, "gaborpallos" <gaborpal...@...> wrote: > > > I have MyApplication.mxml and a CustomComponent.mxml. > > > > > > > > [ MyApplication.mxml ] > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute" xmlns:ns1="*"> > <mx:VBox x="10" y="10"> > <ns1:CustomComponent/> > </mx:VBox> > </mx:Application> > > > > > > > > > [ CustomComponent.mxml ] > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:HBox x="10" y="10"> > <mx:Button id="myButton" label="Create New"/> > <mx:Label text="CustomComponent"/> > </mx:HBox> > </mx:Canvas> > > > > > > > > > Please I need Your help about how to create a new instance of > CustomComponent all the time when I clicked on myButton? > > Any comment and advice are very useful for me. > > > > > Best Regards, > > Gabor >