AS3:添加事件监听器加载的SWF监听器、加载、事件、SWF

2023-09-08 12:21:31 作者:下一站↘婞諨

好吧,也许我刚喝了太多的啤酒,在这一点上,但 - 我只是想监听来自一个swf我已经加载的自定义事件,我只是不能够捕捉到它。装载code,现在仅仅是:

ok, maybe i've just had too much beer at this point but - i'm just trying to listen for a custom event from a swf i've loaded and i'm just NOT able to capture it. the loading code right now is just:


  public function loadGame(gameSrc:String,gX:Number,gY:Number):void {
        var loader = new Loader();
           var addedDefinitions:LoaderContext = new LoaderContext();
           addedDefinitions.applicationDomain = new ApplicationDomain();   
     loader.load(new URLRequest(gameSrc));
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded);

     function onLoaded(evt:Event):void {   
    var game:MovieClip = MovieClip(evt.target.content);

    game.x = gX;
    game.y = gY;    

    chamber.mc_gameHolder.addChild(game);    
    Tweener.addTween(chamber.mc_gameTitle,{alpha:1,time:.75});  

    game.addEventListener("showQuiz",showQuiz);  
   }

  }

我已经试过像一吨的方法可以做到这一点,他们都不奏效。我知道的情况是从我加载的SWF解雇了,因为我也有听众在那里,描绘出一个你好时,它的发射。

i've tried like a ton of ways to do this and NONE of them work. i know the event is being fired from my loaded swf because i also have a listener in there that traces out a "hello" when it's fired.

人?和道歉,如果这已经公布之前 - 搜索没来具体的东西。

anyone? and apologies if this has been posted before - search didn't turn up anything specific.

推荐答案

我遇到了同样的问题。以下是你需要做的。当实例化你的的LoaderContext,确保的LoaderContext使用SecurityDomain.currentDomain的。这将解决您的问题。

I ran into the same problem. Here is what you need to do. When instantiating your LoaderContext, make sure the LoaderContext is using SecurityDomain.currentDomain. That will solve your problem.