0

I need to get URL of my SWF from ActionScript 3 in order to parse it (cannot use loaderInfo.parameters).

I've tried to use root.loaderInfo.url but it returns null. FlexGlobals.topLevelApplication.url throws an error, because topLevelApplication doesn't exist. Am I missing something?

1
  • 1
    Did you try to get FlexGlobals.topLevelApplication.url after Application initialized? ex) This doesn't work because this code try to get before Application initialized event. public var url:String = FlexGlobals.topLevelApplication.url; Commented Oct 8, 2015 at 11:22

1 Answer 1

2

OK, got it. As Yasuyuki Uno suggested in the comment, url property should be called after INIT event.

So I had

public function MyClass()
{
    root.loaderInfo.url;  // null
}

And it should be

import flash.events.Event;

public function MyClass()
{
    root.loaderInfo.addEventListener(Event.INIT, _onInit);
}

private function _onInit(ev:Event) : void
{
    root.loaderInfo.url;  // we have the URL now
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.