Loader crushes after loaded

There is simple swf loader :

package;

import openfl.display.Bitmap;
import openfl.display.Loader;
import openfl.display.Sprite;
import openfl.Lib;
import openfl.display.StageQuality;
import openfl.display.StageScaleMode;
import openfl.events.Event;
import openfl.events.ProgressEvent;
import openfl.net.URLLoader;
import openfl.net.URLRequest;
import openfl.utils.Assets;
/**
 * ...
 * @author IN4CORE PROGRESSIONS
 */
class CTMLoader extends Sprite 
{
	private var loader:Loader = new Loader();
	private var line:Bitmap = new Bitmap(Assets.getBitmapData("img/line.png"));
	private var light:Bitmap = new Bitmap(Assets.getBitmapData("img/light.png"));
	private var back:Bitmap = new Bitmap(Assets.getBitmapData("img/back.png"));
	
	public function new() 
	{
		super();
		
		stage.scaleMode = StageScaleMode.SHOW_ALL;
		stage.quality	= StageQuality.HIGH;
		stage.align = "T";
		
		addEventListener(Event.ADDED_TO_STAGE, init);
	}
	
	private function init(e:Event):Void 
	{
		removeEventListener(Event.ADDED_TO_STAGE, init);
		
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
		loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
		
		loader.load(new URLRequest("some.swf"));
		
		addChild(back);
		addChild(line);
		addChild(light);
		
		back.x = stage.stageWidth / 2 - back.width / 2;
		back.y = stage.stageHeight - back.height - 200;
		
		line.x = back.x + 8;
		line.y = back.y + 5;
		
		light.x = line.x + line.width - 5;
		light.y = back.y + 4;
	}
	
	private function onProgress(e:ProgressEvent):Void 
	{
		line.width = e.bytesLoaded / e.bytesTotal * 350;
		light.x = line.x + line.width - 5;
	}
	
	private function onComplete(e:Event):Void 
	{
		loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
		loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
		
		removeChild(back);
		removeChild(line);
		removeChild(light);
		
		addChild(loader);
	}

}

After loaded - by timeout loads starts again, what a bug? I think its loaders coflict in Main game and CTMLoader. What i can do for ? (p.s if i use other swf compiled by FD AS3 target, not HAXE + openfl - all good, but haxe+openFl - starts load agan and again infinitly )

See this topic:

Very very big thanks!!!

1 Like

Yeah, I think long-term we should do ApplicationMain_8468 or some automatically generated name, to try and make SWFs more compatible with each other.

I created an enhancement task here: