Yep, my bad. As Jonathan points out, this should be enterState instead of onEnter (grr).
<mx:State name="editing" enterState="localeEditor.myTextBox.setFocus() "> -TH --- In flexcoders@yahoogroups.com, "Tim Hoff" <[EMAIL PROTECTED]> wrote: > > > Hi João, > > This is kind of a hack, but you could try: > > <mx:State name="editing" onEnter="localeEditor.myTextBox.setFocus() "> > > If you used this, you would want to execute the setFocus code on > creationComplete of the editor; for the first time that the editor is > shown. Instead of useing states for something like this though, you > might want to consider using a ViewSTack instead. For those the "show" > event, in conjunction with creationComplete, would work; when changing > the container's selectedIndex. > > -TH > > --- In flexcoders@yahoogroups.com, João joao.saleiro@ wrote: > > > > Hello, > > > > I have a: > > > > - Container with two states ( "" and "editing") > > - A view (LocaleEditor.mxml) that is shown when the container changes > > to the state "editing": > > > > <mx:states> > > <mx:State name="editing" > > > <mx:RemoveChild target="{listaDeLocales}"/> > > <mx:AddChild relativeTo="{gestorDeLinguas}" position="lastChild"> > > <ns1:LocaleEditor id="localeEditor"/> > > </mx:AddChild> > > </mx:State> > > </mx:states> > > > > I need my view to execute some code when it is shown > > (myTextBox.setFocus() ). I have tried the creationComplete event, but > > the view is only created on the first time the state changes, the next > > times this event is not dispatched. I have tried the AddedToStage, but > > it throws a runtime error with the myTextBox.setFocus() code . I have > > tried the "show" event, but it simply doesn't work. > > > > Which event should I rely on to execute the "myTextBox.setFocus()" > > when the user sees the view? > > > > Thanks, > > > > João Saleiro > > >