Skip to main content
Participating Frequently
May 22, 2015
Question

AIR mobile + external swf + mouse behavior

  • May 22, 2015
  • 1 reply
  • 480 views

Good day!

Faced with a very strange situation.

Create an AIR-mobile project, there are simple loader of external swf (without code, just one clip with Shape in it), setting up LoaderContext, all as it should be. I tried to load a file from the disk, locally and from the site and from local storage application (app-storage).

Everything is loaded, and I set up mouse events for the loaded clip, for the stage and for created manually sprite.

And here begins the strangeness - mouse events do not stack up on the display objects list, ie, if we click on the sprite - event only gets this sprite, but not the parent clip and not a stage, if we click the clip - event only gets this clip, but not the stage.

I put exactly the same code in the AIR-flashplayer project and events work as expected. Only difference here - call Security.allowDomain ("*"), which for mobile-version certainly is not working.

What is it? Can someone help me?

Here's the sample code:

  private function testLoad3(a_strURL:String): void

  {

  var loader:Loader;

  var context:LoaderContext;

       loader = new Loader();

       context = new LoaderContext(false, ApplicationDomain.currentDomain, null);

       loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

       loader.load(new URLRequest(a_strURL), context);

  }

  private function onComplete(e:Event):void

  {

  var loader:Loader = LoaderInfo(e.currentTarget).loader;

  var content:MovieClip = loader.content as MovieClip;

       addChild(content);

       var clip:Sprite = new Sprite();

       clip.graphics.beginFill(0x00FF00, 0.5);

       clip.graphics.drawRect(200, 200, 200, 200);

       clip.buttonMode = true;

       content.addChild(clip);

       clip.addEventListener(MouseEvent.CLICK, onClickSprite);

       content.addEventListener(MouseEvent.CLICK, onClickClip);

       stage.addEventListener(MouseEvent.CLICK, onClickStage);

  }

  private function onClickSprite(e:MouseEvent):void

  {

       trace("Sprite clicked");

  }

  private function onClickClip(e:MouseEvent):void

  {

       trace("Clip clicked");

  }

  private function onClickStage(e:MouseEvent):void

  {

       trace("Stage clicked");

  }

This topic has been closed for replies.

1 reply

Inspiring
May 27, 2015

are you aware of the differences between $event.target and $event.currentTarget?

flash - Difference between e.target and e.currentTarget - Stack Overflow

AlexBnewAuthor
Participating Frequently
June 1, 2015

No, I have mouse events do not fire at all.