I don't think your onInit function ever fires - what does your controller
class extend?

On Sun, Apr 20, 2008 at 10:51 PM, dnk <[EMAIL PROTECTED]> wrote:

>   Ok, I have a controller class that has an onInit function that is
> fired form a class constructor. For some reason when I call a function
> from there, it never fires.....
>
> This is a partial code snippet.
>
> // Constructor
> public function dirTestController()
> {
> //turn the key, start it up....
> addEventListener( FlexEvent.CREATION_COMPLETE, onInit );
> }
>
> private function onInit( event:Event ):void
> {
> //setup event listeners
> systemManager.addEventListener( getDirEvent.GET_DIRECTORY_EVENT,
> handler_GetDirectoryEvent );
>
> // get the initial data
>
> // ----> THIS NEVER FIRES
> getDirectoryData();
> }
>
> public function getDirectoryData(evt:Event):void
> {
> // fire an event(s) to get the initial data
> dispatchEvent (new getDirEvent(getDirEvent.GET_DIRECTORY_EVENT));
> }
>
> To work around it, I used this (and it works):
>
> private function onInit( event:Event ):void
> {
> //setup event listeners
> systemManager.addEventListener( getDirEvent.GET_DIRECTORY_EVENT,
> handler_GetDirectoryEvent );
>
> // Set a timer since the below function does not seem to get fired.
> var myTimer:Timer = new Timer(1, 1);
> myTimer.addEventListener("timer", getDirectoryData);
> myTimer.start();
> }
>
> Now I have found a way around it by using a timer class, but I am
> wondering why the original would not work? When i call the
> getDirectoryData function from a button click or so on, the data comes
> in without issue. And obviously it works when dispatched by a timer,
> etc.
>
> dnk
>
>  
>

Reply via email to