Return to Snippet

Revision: 37029
at December 2, 2010 21:23 by weavermedia


Updated Code
import flash.display.*;
import flash.events.*;

private function loadAsset(loadURL:String):void
{
	var ldr:Loader = new Loader();
	ldr.load(new URLRequest(loadURL));
	ldr.contentLoaderInfo.addEventListener(Event.INIT, loadStart);
	ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
	ldr.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, loadError);
	ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
	ldr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);
}

private function loadStart(e:Event):void
{
	trace("load start");
	ldr.contentLoaderInfo.removeEventListener(Event.INIT, loadStart);
}

private function loadError(e:Event):void
{
	trace("load error");
	ldr.contentLoaderInfo.removeEventListener(ErrorEvent.ERROR, loadError);
	ldr.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
	ldr.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);
}

private function loadComplete(e:Event):void
{
	trace("load complete");
	ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
	addChild(event.target.content) as MovieClip;
}

Revision: 37028
at December 2, 2010 21:19 by weavermedia


Updated Code
var loadURL:String = "http://www.some-domain.com/some-name.swf";
var ldr:Loader = new Loader();
ldr.load(new URLRequest(loadURL));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loadStart);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
ldr.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, loadError);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
ldr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);

function loadStart(e:Event):void
{
	ldr.contentLoaderInfo.removeEventListener(Event.INIT, loadStart);
	trace("load start")
}

function loadError(e:Event):void
{
	ldr.contentLoaderInfo.removeEventListener(ErrorEvent.ERROR, loadError);
	ldr.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
	ldr.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);
	trace("load error")
}

function loadComplete(event:Event):void
{
	ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
	trace("load complete");
	addChild(event.target.content) as MovieClip;
}

Revision: 37027
at December 2, 2010 21:06 by weavermedia


Updated Code
var loadURL:String = "http://www.some-domain.com/some-name.swf";
var ldr:Loader = new Loader();
ldr.load(new URLRequest(loadURL));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loadStart);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
ldr.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, loadError);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
ldr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);

function loadStart(e:Event):void {trace("load start")}
function loadError(e:Event):void {trace("load error")}
function loadComplete(event:Event):void
{
	trace("load complete");
	addChild(event.target.content) as MovieClip;
}

Revision: 37026
at December 2, 2010 21:04 by weavermedia


Initial Code
var loadURL:String = "http://www.imagecache365.com/Promotions/bingo/Xmas2010/prize_break.swf";
var ldr:Loader = new Loader();
ldr.load(new URLRequest(loadURL));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loadStart);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
ldr.contentLoaderInfo.addEventListener(ErrorEvent.ERROR, loadError);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadError);
ldr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadError);

function loadStart(e:Event):void {trace("load start")}
function loadError(e:Event):void {trace("load error")}
function loadComplete(event:Event):void
{
	trace("load complete");
	addChild(event.target.content) as MovieClip;
}

Initial URL

                                

Initial Description

                                

Initial Title
AS3 Load external SWF from URL

Initial Tags

                                

Initial Language
ActionScript 3