[flexcoders] Re: Which event is dispatched when the view is shown by a stage change?
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 [EMAIL PROTECTED] 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
[flexcoders] Re: Which event is dispatched when the view is shown by a stage change?
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
[flexcoders] Re: Which event is dispatched when the view is shown by a stage change?
Hi Jonathan, thanks for your great post! About the two solutions, I don't like both, but having to choose I would go with the first one. In the way I see it, the component should never know where he's in. The component should only know now I'm visible... now I'm not, and react to that. Both solutions are hacks. The Flex SDK should have a proper solution for this problem. Maybe I should file this as a feature request on the Adobe JIRA? Thanks, João Saleiro