In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ProgressEvent発生後、bytesLoadが取得できる

Get Adobe Flash player
by katapad 29 Aug 2009
    Embed
package {
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	import flash.net.*;
	import flash.utils.getTimer;
	public class FlashTest extends Sprite {
		private var txt:TextField;
		public function FlashTest() {
			txt = addChild(new TextField()) as TextField;
			txt.multiline = true;
			txt.wordWrap = true;
			txt.width = stage.stageWidth;
			txt.height = stage.stageHeight;
			txt.defaultTextFormat = new TextFormat("_sans");
			txt.text = "ProgressEventが発生しないとbytesLoadなどが取得できないことを確認するサンプルです。\n\t-Event.Open\n\t-Event.COMPLETE\n\t-ProgressEvent.PROGRESS\n\nのイベントを監視しています\n\n■結果\n";

			var loader:URLLoader = new URLLoader();

			loader.addEventListener(Event.OPEN, tracer);
			loader.addEventListener(Event.COMPLETE, tracer);
			loader.addEventListener(ProgressEvent.PROGRESS, tracer);
			loader.dataFormat = URLLoaderDataFormat.BINARY;
			//loader.load(new URLRequest("http://k.yimg.jp/images/top/sp/logo.gif?" + new Date().getTime()));
			loader.load(new URLRequest("http://swf.wonderfl.net/swf/usercode/c/c8/c849/c84995a53248da9d63cce89cdd637d592ae42f17.swf?t=1251530010156&q=" + new Date().getTime()));
		}
		private function tracer(event:Event):void
		{
			txt.appendText("event.type: " + event.type + " | " +  event.target.bytesLoaded + " / " + event.target.bytesTotal + ";\n");
		}
	}
}