Hello everyone, today I'm trying to get the URL where my Flash movie is sitting on.
I found a similar question here, which was answered with a link to Flash's LoaderInfo method, but I'm not sure I'm using it correctly as the textField in my test movie here: http://leongaban.com/stackoverflow/getUrl/ does not display the URL
Updated! WORKING CODE
All I needed was this: stage.loaderInfo.url
:)
package {
import flash.display.Stage;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import FontsTest;
public class LoaderInfoExample extends Sprite
{
private var myTextField :TextField = new TextField();
private var urlIs:String = "";
public function LoaderInfoExample() {
urlIs = stage.loaderInfo.url;
trace(stage.loaderInfo.url);
addEventListener(Event.ADDED_TO_STAGE, initHandler);
}
private function initHandler(event:Event):void {
myTextField.defaultTextFormat = FontsTest.Arial14Bold;
myTextField.border = true;
myTextField.antiAliasType = flash.text.AntiAliasType.ADVANCED;
myTextField.selectable = true;
myTextField.mouseEnabled = true;
myTextField.autoSize = TextFieldAutoSize.LEFT;
myTextField.text = "Url is = "+urlIs;
addChild(myTextField);
}
}
}