Hi theo, Thanks for your answers. I already tested your first solution but i don't be satisfied because, in my mxml code, i have to define exactly how many canvas i want to display. is it possible to display canvas (mxml component) into a canvas object of a mxml application whithout define exactly the number of canvas component i want to display ? i don't know your second answer. i try it but i also have to define the number of canvas i want to use. maybe, it's not possible to do what i want and i'll be able to use the viewstack object...
Titipouns --- In flexcoders@yahoogroups.com, "Theo" <[EMAIL PROTECTED]> wrote: > > Hi Titipouns, > > It's me again. Here is my second solution to the question you posted: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > xmlns:com="*" layout="absolute"> > > <mx:states> > <mx:State name="addCanvas01"> > <mx:AddChild position="lastChild"> > <mx:target> > <com:Canvas01 x="120" y="112"/> > </mx:target> > </mx:AddChild> > </mx:State> > <mx:State name="addCanvas02"> > <mx:AddChild position="lastChild"> > <mx:target> > <com:Canvas02 x="120" y="112"/> > </mx:target> > </mx:AddChild> > </mx:State> > </mx:states> > > <mx:Canvas id="canvas_father" backgroundColor="0xff0000" x="120" > y="112" width="400" height="400"> > </mx:Canvas> > > <mx:Button x="197" y="24" label="Display canvas01 on canvas_father" > click="currentState='addCanvas01'"/> > > <mx:Button x="197" y="54" label="Display canvas02 on canvas_father" > click="currentState='addCanvas02'"/> > > </mx:Application> > > In this solution I use MXML states to define two states that will show > the two Canvas components. The two Canvas components remain as they are. > > First, notice that I needed to add an additional namespace declaration > to the Application tag. This allows me to use the two Canvas > components. I use the prefix "com" and keep the two components in the > same folder and the main application file. > > I then use the AddChild tag to add the Canvas component at the same > location of the parent Canvas. > > The two buttons can then change the currentState upon the click event. > > I hope this helps. > > Theo > http://therush.wordpress.com > > --- In flexcoders@yahoogroups.com, "titipouns19" <titipouns19@> wrote: > > > > Hello, > > > > I want to display the component canvas01 or the component canvas02 on > > a canvas object who is in a mxml application file. > > How can i do this ? > > > > canvas01 : > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" > > height="400"> > > > > <mx:Label x="142" y="28" text="Affichage canvas 01"/> > > > > </mx:Canvas> > > > > canvas02 : > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" > > height="400"> > > > > <mx:Label x="142" y="28" text="Affichage canvas 02"/> > > > > </mx:Canvas> > > > > mxml application file : > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > layout="absolute"> > > > > <mx:Canvas id="canvas_father" x="120" y="112" width="400" > > height="400"> > > </mx:Canvas> > > > > <mx:Button x="197" y="24" label="Display canvas01 on > > canvas_father"/> > > > > <mx:Button x="197" y="54" label="Display canvas02 on > > canvas_father"/> > > > > </mx:Application> > > > > > > Thanks for your answer. > > > > Titipouns > > >