2011年5月23日 星期一

DisplayObject.loaderInfo屬性參照LoaderInfo物件__取得目前swf的URL

DisplayObject.loaderInfo屬性傳回LoaderInfo物件
this.root.loaderInfo.url取得目前swf的URL,呈現在TextField
1000523_DisplayObject.loaderInfo.swf


package  {

import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

public class DisplayObject_loaderInfo_1000523 extends MovieClip {

public function DisplayObject_loaderInfo_1000523() {
/*flash.display.DisplayObject.loaderInfo屬性,傳回loaderInfo物件*/
/*var loaderPosStr:String = this.loaderInfo.url;  <---這樣也行*/
var loaderPosStr:String = this.root.loaderInfo.url;
this.createTF(decodeURIComponent(loaderPosStr));
return;
}

private function createTF(_loaderPosStr:String):void{
var tfFormat:TextFormat = new TextFormat();
tfFormat.size = 18;
tfFormat.color = 0x000088;

var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.wordWrap = true;
tf.multiline = true;
tf.defaultTextFormat = tfFormat;
tf.width = 450;
tf.x = 50;
tf.y = 50;
this.addChild(tf);
tf.text = _loaderPosStr;
return;
}
}

}

沒有留言: