views:

13

answers:

1

Hi I am writing a flex application that has a MainMovie that loads flex programs (ChildMovie) depending on what the user selects in the MainMovie. below is some pseudocode to help me describe my problem hopefully.

class MainMovie{

  private var request:URLRequest = new URLRequest();

  public function callPHPfile(param:String, loader:URLLoader,   
             handlerFunction:Function):void {

    var parameter:URLVariables=new URLVariables();
    parameter.param = param;
    request.method = URLRequestMethod.POST;
    request.data = parameter;
    request.url = php file on server;
    loader.addEventListener(Event.COMPLETE, handlerFunction);
    loader.load(request);
  }

}

Class ChildMovie {

   private var loaderInChild:URLLoader = new URLLoader();

   public function handlerInChild(e:Event):void {
      process data....
      loaderInChild.removeEventListerner(Event.COMPLETE, handlerInChild);
   }  



   private function buttonClickHandler(e:Event):void{
      Application.application.callPHPfile(param, loaderInChild, handlerInChild)
   }
}

I can see that the callPHPfile function is being executed and received xml data from in httpFox, the problem is that the code in the handlerInChild function is not being executed. What am I doing wrong here?

+1  A: 

It was a runtime error. I forgot that i uninstalled flash player debugger in firefox and it didn't show. in the handlerInChild function, there is a line

var data:XML = loader.data;

it should be

var data:XML = XML(loader.data);

and the code will run as expected.