Thanks very much! It looks as though the transition will work - or not - depending on when it's invoked in the component creation process. And invoking it at the wrong time (ie as part of initialisation, as I did) prevents it from working later, as in your solution.
Transitions seem to have a very steep learning curve. The solution for the toy example /still/ doesn't work in my real application! So there must be some other inexplicable glitch to be isolated... --- In flexcoders@yahoogroups.com, Haykel BEN JEMIA <hayke...@...> wrote: > > I don't know why it's behaving like that, but it seems to work if you set > the state after the form item has been created, like this: > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > <mx:Form> > <mx:FormItem label="Type" creationComplete="st.currentState='taskQueue'"> > <view:SectionTypeControl id="st" /> > </mx:FormItem> > </mx:Form> > </mx:Application> > > Anyone has an explanation? > > Haykel Ben Jemia > > Allmas > Web & RIA Development > http://www.allmas-tn.com > > > > > On Mon, Jan 19, 2009 at 5:59 PM, mauricen <maur...@...>wrote: > > > I have a component which can appear initially in one of two states, and > > can subsequently be switched between them. When this switch takes place, > > I want a transition to occur. Here's a tiny model of my component: > > > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> > > <mx:states> > > <mx:State name="state1"> > > <mx:AddChild> > > <mx:HBox> > > <mx:Text id="text1" text="t1:"/> > > <mx:Text id="text2" text="t2:"/> > > </mx:HBox> > > </mx:AddChild> > > </mx:State> > > </mx:states> > > <mx:transitions> > > <mx:Transition> > > <mx:Move targets="{[text1, text2]}"/> > > </mx:Transition> > > </mx:transitions> > > </mx:Canvas> > > > > If I embed this component (call it MyComp) like this: > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > > <view:MyComp currentState="state1"/> > > </mx:Application> > > > > the transition takes place as the component appears, and everything is > > fine. But if I put it inside a FormItem, like this: > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > > <mx:Form> > > <mx:FormItem label="Type"> > > <view:SectionTypeControl currentState="taskQueue"/> > > </mx:FormItem> > > </mx:Form> > > </mx:Application> > > > > the transition never takes place and the two labels remain superimposed. > > > > In fact the problem is a little worse than this. In the toy > > application above, you can replace FormItem by a container like HBox > > and it works again. But in my real app I can't use it inside a Form > > at all. What gives? > > > > Maurice > > > > > > >