Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now