(Flash target)
Z order is not work with Loader. I guess it was wrong above OpenFL 4.5.2.
Simple test code:
- child
class Main extends Sprite
{
public function new()
{
super();
// Assets:
var circle = Assets.getBitmapData("img/bottom.png");
var bitmap = new Bitmap(circle);
this.addChild(bitmap);
}
}
- loader
class Main extends Sprite
{
private var loader:Loader;
public function new()
{
super();
this.name = "main";
Security.allowDomain("*");
Security.allowInsecureDomain("*");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.name = "bottom.loader";
loader.x = 20;
var request = new URLRequest("child swf url");
loader.load(request);
}
private function onComplete(event:Event):Void
{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
addChild(loader);
var bitmap = new Bitmap(Assets.getBitmapData("img/up.png"));
bitmap.name = "top.bitmap";
addChild(bitmap);
var idx = getChildIndex(bitmap);
trace("bitmap index: " + idx, "parent name: " + bitmap.parent.name);
idx = getChildIndex(loader);
trace("loader index: " + idx, "parent name: " + loader.parent.name, "x value: " + loader.x);
}
}
Result:
Trace result:
Main.hx:47: bitmap index: 1,parent name: main
Main.hx:50: loader index: 0,parent name: main,x value: 20
Loader’s x value is 20 but not work. But, when I down grade OpenFL to 4.5.2(Lime 3.5.2), everything is ok.
How can I fix this error?