flash on 2009-12-26

by zahir
♥0 | Line 48 | Modified 2009-12-26 03:45:41 | MIT License
play

ActionScript3 source code

/**
 * Copyright zahir ( http://wonderfl.net/user/zahir )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4tZO
 */

package{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;
	import flash.system.Security;
	import flash.text.TextField;

	public class LaodZip extends Sprite{
		private const url:String  = "http://zahir.coresv.com/zahir/img.zip";
		private var l:URLLoader;
		private var t:TextField;
		//zahir.s69.coreserver.jp
		public function LaodZip(){
			Security.loadPolicyFile( "http://zahir.coresv.com/zahir/crossdomain.xml" );
			
			t = new TextField();
			t.width = t.height = 465;
			addChild(t);
			
			l = new URLLoader();
			l.addEventListener(Event.COMPLETE, onComp);
			l.addEventListener(ProgressEvent.PROGRESS, onProg);
			l.addEventListener(IOErrorEvent.IO_ERROR, onIOErr);
			l.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSCRTYErr);
			
			l.dataFormat = "binary";
			var lc:LoaderContext = new LoaderContext(true);
			
			
			var req:URLRequest = new URLRequest( url );
			l.load( req );
		}
		private function onComp(e:Event):void{
			l.removeEventListener(Event.COMPLETE, onComp);
			l.removeEventListener(ProgressEvent.PROGRESS, onProg);
			l.removeEventListener(IOErrorEvent.IO_ERROR, onIOErr);
			l.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSCRTYErr);
			
			t.text = "Complete !!"
		}
		private function onProg(e:ProgressEvent):void{
			t.text = String( e.bytesLoaded / e.bytesTotal ) + "%";
		}
		private function onIOErr(e:IOErrorEvent):void{
			t.text = "IO Error !!";
		}
		private function onSCRTYErr(e:SecurityErrorEvent):void{
			t.text = "Security Error !!";
		}
	}
}