This content has been marked as final. Show 7 replies
Try the focusIn event.
no joy with the focusIn event :(
my component is embedded within a vBox and every time the component is seleted / viewed / openend etc... (Not just created!) I want to run a function within this component....
Well, this all depends on the exact nature of your component and what it means to be selected, viewed, and opened. More details are required.
Ok – sorry I am reasonably new to flex, so my terminology and descriptions may be a bit off when trying to explain myself….. let me try again.
My main MXML Application file contains an ApplicationControlBar containing a ViewStack that then links to the other components within my application etc... :
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:mi="components.*" layout="absolute">
<mi:page1 id="page_1" label="page1"/>
<mi:page2 id="page_2" label="page2"/>
<mi:page3 id="page_3" label="page3"/>
<mi:page4 id="page_4" label="page4"/>
then when one of the "links" is selected for the 1st time.... if I call a function on the creationComplete event and everything works fine and as it is supposed to.... but after the page has been created the creationComplete event will not run again - for example if I leave the page / component and return to it.......
I need the function to run every time the component is "returned to" whether it has been created or not, because in some cases I send ID's and other variables through DataGrid click events etc....
Do you understand what I am trying to do / what I am getting at…. ?
Thanks, and sorry for any inconvenience,
You can make use of the ViewStack's "change" event. eg:
<mx:ViewStack id="menu_vs" change="onChange(event)">
private function onChange(event: IndexChangedEvent): void
The event will fire everytime the user changes the page. You've also got more state info in the IndexChangedEvent class (check the docs). The only thing is that this doesn't fire on first creation (since a page hasn't changed). You'll have to take care of that case.
I understand what you say about the "IndexChangedEvent" and have tried it and it works, although it in my caase I want to run a function that is within the .mxml file that the Viewstack changes to / displays, not the main application .mxml file where the viewstack is being initialised etc....
do you understand what I mean??
Same thing. Instead of: