Index: trunk/as3/com/jeroenwijering/player/SWFLoader.as
===================================================================
--- trunk/as3/com/jeroenwijering/player/SWFLoader.as	(revision 57)
+++ trunk/as3/com/jeroenwijering/player/SWFLoader.as	(revision 60)
@@ -26,6 +26,4 @@
 	/** Base directory for the plugins. **/
 	private var basedir:String = 'http://plugins.longtailvideo.com/';
-	/** Amount of plugins still to load. **/
-	private var amount:Number;
 
 
@@ -37,5 +35,4 @@
 	public function SWFLoader(ply:MovieClip):void {
 		player = ply;
-		amount = 0;
 	};
 
@@ -44,13 +41,10 @@
 	* Load a list of SWF plugins.
 	*
-	* @prm pgi		A commaseparated list with plugins. 
+	* @prm pgi	A commaseparated list with plugins.
 	**/
 	public function loadPlugins(pgi:String=null):void {
 		if(pgi) {
 			var arr = pgi.split(',');
-			amount = arr.length;
 			for(var i in arr) { loadSWF(arr[i],false); }
-		} else { 
-			dispatchEvent(new Event(Event.COMPLETE));
 		}
 	}; 
@@ -67,5 +61,5 @@
 		} else {
 			skin = player['player'];
-			dispatchEvent(new Event(Event.INIT));
+			dispatchEvent(new Event(Event.COMPLETE));
 		}
 	};
@@ -79,10 +73,10 @@
 			ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,skinError);
 			ldr.contentLoaderInfo.addEventListener(Event.INIT,skinHandler);
-		} else { 
+		} else {
 			skin.addChild(ldr);
 			ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,pluginError);
 			ldr.contentLoaderInfo.addEventListener(Event.INIT,pluginHandler);
 		}
-		if(player.loaderInfo.url.indexOf('http://') == 0) {
+		if(player.loaderInfo.url.indexOf('http') == 0) {
 			var ctx = new LoaderContext(true,ApplicationDomain.currentDomain,SecurityDomain.currentDomain);
 			if(skn) { 
@@ -97,10 +91,7 @@
 
 
-	/** SWF loading failed; use default skin. **/
+	/** SWF loading failed. **/
 	private function pluginError(evt:IOErrorEvent):void {
-		amount--;
-		if (amount == 0) {
-			dispatchEvent(new Event(Event.COMPLETE));
-		}
+		player.view.sendEvent('trace',' plugin: '+evt.toString());
 	};
 
@@ -108,9 +99,9 @@
 	/** Plugin loading completed; add to stage and populate. **/
 	private function pluginHandler(evt:Event):void {
-		var clp = evt.target.content;
-		player.addPlugin(clp);
-		amount--;
-		if (amount == 0) {
-			dispatchEvent(new Event(Event.COMPLETE));
+		var plg = evt.target.content;
+		try { 
+			plg.initializePlugin(player.view);
+		} catch(err:Error) { 
+			player.view.sendEvent('trace',' plugin: '+err.message);
 		}
 	};
@@ -120,5 +111,5 @@
 	private function skinError(evt:IOErrorEvent=null):void {
 		skin = player['player'];
-		dispatchEvent(new Event(Event.INIT));
+		dispatchEvent(new Event(Event.COMPLETE));
 	};
 
@@ -131,5 +122,5 @@
 			Draw.clear(player);
 			player.addChild(skin);
-			dispatchEvent(new Event(Event.INIT));
+			dispatchEvent(new Event(Event.COMPLETE));
 		} else {
 			skinError();
