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

Bring loaded external swf to the front

New Here ,
Jan 26, 2013 Jan 26, 2013

Hi,

I am now implementing to create a website using side scrolling platform game approach. Since the player/actor (character that moves according to keyborad events) should always be at the top layer, I am having difficulties to get my loaded swf on top of the player. I am currently using Flash cs6 (as3).

Basically, in my main stage, there are 3 layers. 1 for actionscript, the scond one for player and lastly for background.

Layer player contains player mc and background mc.

Background mc contains visual and collisions layers.

Anything that got to do with visual, i have to put it in visual layer.

In visual layer i have backgroundcontainer mc

So, as i put the button in the backgroundcontainer mc to call the external swf, the loaded external swf appears in the container.

(I am using load/unload snippet code to call the external swf)

I want the external swf to appear on top of the player.

---------------------------------------------------------------------------------------------

for (var fl_ChildIndex_2:int = 0;

        fl_ChildIndex_2 < this.numChildren;

        fl_ChildIndex_2++)

{

    this.getChildAt(fl_ChildIndex_2).addEventListener(MouseEvent.CLICK, fl_ClickToBringToFront_2);

}

 

function fl_ClickToBringToFront_2(event:MouseEvent):void

{

    this.addChild(event.currentTarget as DisplayObject);

}

---------------------------------------------------------------------------------------------

Any help would greatly appreciated 

TOPICS
ActionScript
457
Translate
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

correct answers 1 Correct answer

LEGEND , Jan 27, 2013 Jan 27, 2013

If you want an object to move atop all others you can just use addChild(thatobject), where thatobject is the item you want to move atop anything else.  I don't know what object(s) your loop is attempting to act on, but it appears to be trying to change the index of all child objects rather than just one.

Translate
LEGEND ,
Jan 27, 2013 Jan 27, 2013
LATEST

If you want an object to move atop all others you can just use addChild(thatobject), where thatobject is the item you want to move atop anything else.  I don't know what object(s) your loop is attempting to act on, but it appears to be trying to change the index of all child objects rather than just one.

Translate
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