0

嗨,我正在编写一个具有 MainMovie 的 flex 应用程序,该应用程序根据用户在 MainMovie 中选择的内容加载 flex 程序(ChildMovie)。下面是一些伪代码,希望能帮助我描述我的问题。

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)
   }
}

我可以看到 callPHPfile 函数正在执行并从 httpFox 中接收 xml 数据,问题是 handlerInChild 函数中的代码没有被执行。我在这里做错了什么?

4

1 回答 1

1

这是一个运行时错误。我忘了我在 Firefox 中卸载了 Flash Player 调试器,但它没有显示。在 handlerInChild 函数中,有一行

var data:XML = loader.data;

它应该是

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

并且代码将按预期运行。

于 2010-07-19T08:03:08.830 回答