вторник, 21 октября 2008 г.

Application.application.url in Flash AS3 //Доступ к информации загрузчика

Application.application.url in Flash AS3, renaun.com

The solution to accessing the loader information url property is quite easy in Flash ActionScript 3. But when you Google for the solution its not obvious. Hence I am creating a post about it.

In Flex you can access the url of the SWF by accessing Application.application.url. What this value represents is the root.loaderInfo.url property. So in Flash and AS3 you would do this:

var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = true;

tf.appendText("params:" + "\n");
try {
var keyStr:String;
var valueStr:String;
tf.appendText(LoaderInfo(this.root.loaderInfo).url + "\n");
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
tf.appendText("\t" + keyStr + ":\t" + valueStr + "\n");
} catch (error:Error) {

The important part is accessing the root's loaderInfo object. The above code also shows how to access the FlashVar parameters in ActionScript 3.

Example code referenced from here.

1 комментарий:

Анонимный комментирует...

разработка предприятия разработка сайтов http://web-miheeff.ru разработка предприятия