• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

AIR mobile + external swf + mouse behavior

Community Beginner ,
May 22, 2015 May 22, 2015

Copy link to clipboard

Copied

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");

  }

TOPICS
Development

Views

372

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 27, 2015 May 27, 2015

Copy link to clipboard

Copied

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

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines