Skip to main content
campbellma
Inspiring
April 27, 2014
Answered

Adjust Layer Order with AS3

  • April 27, 2014
  • 1 reply
  • 1674 views

I want to load an external SWF into my project. I do so by adding a Loader to the stage. It appears above everything, there are 16 layers in my FLA and I want to put it between the second and third to bottom layers. How would I do this? I looked up some things online but all of them are for change object order on the same layer, and they usually invole making 2 or three objects with AS3 then changing order on the same layer, still above objects that are actually on the stage in the FLA. I want to put the loaded SWF below ALREADY EXISTING OBJECTS that are on different layers.

My code:

var pageLoader:Loader = new Loader;

addChild(pageLoader);

pageLoader.x=98;

pageLoader.y=121;

//pageLoader.z <--- As far as I can tell this only works within one layer, it wont jump from layer to layer.

Some suggested loading my swf into an ampty movie clip, bt when I do that I lose interactivity for the swf, why is that and is there away around this?

My code:

var pageLoader:Loader = new Loader;

pageContainer.addChild(pageLoader);

//pageContainer is an empty movie clip

I want to load it directly to the stage and just change the layer(first method), but if this cannot be done then I need a way to get the swfs loaded into an empty movie clip and keep thier own interactive.

This topic has been closed for replies.
Correct answer campbellma

I dound out about addChildAt, which is different from addChild, becuase it has 2 parameters, the object name and its z-index. So I was able to do:

addChildAt(pageLoader,4);

Then I ran into the same issue with as the empty movie clip method, I lost interactivity. Then I noticed it has movieclips above it covering it because one of them is being used as a blend mode. So I realized the empty movie clip method wasnt working because there are movie clips above it. So I did mouseEnabled=false. And it works, so YAY!!

1 reply

campbellma
campbellmaAuthorCorrect answer
Inspiring
April 27, 2014

I dound out about addChildAt, which is different from addChild, becuase it has 2 parameters, the object name and its z-index. So I was able to do:

addChildAt(pageLoader,4);

Then I ran into the same issue with as the empty movie clip method, I lost interactivity. Then I noticed it has movieclips above it covering it because one of them is being used as a blend mode. So I realized the empty movie clip method wasnt working because there are movie clips above it. So I did mouseEnabled=false. And it works, so YAY!!