Get URL from URLLoader?

Is there an easy / good way to get the url from a urlader object? It seems at least two other people ( this guy and this this guy ) are wondering the same thing. Maybe we can get an answer here?

+3
source share
2 answers
package
{

import flash.net.URLLoader;
import flash.net.URLRequest;

public dynamic class urlURLLoader extends URLLoader
{

    private var _req:URLRequest;

    public function urlURLLoader( request:flash.net.URLRequest = null ):void
    {   super( request );
        _req = request;
    }

    public override function load( request:flash.net.URLRequest ):void
    {   _req = request;
        super.load( request );
    }

    public function get urlRequest( ):URLRequest
    {   return _req;
    }

}
+8
source

This is a good approach. The reverse approach would be to wrap your URLLoader in a class and store the information there if you want the requesting class to be informed that the download has completed and which URL has been loaded successfully.

Would you get something like it

customLoader.url="http://.....";
customLoader.onLoadDelegate = this;
customLoader.load();

public function customLoaderComplete(url:String, data:[Object or whatever you set]) {

}

customLoader URL-

private var url:String;
private var onLoadDelegate:Object;

public function set url(_url:String):void {
  url = _url;
}

public function set onLoadDelegate(_onLoadDelegate:Object):void {
  onLoadDelegate = _onLoadDelegate;
}

, URLLoader .. Event.COMPLETE ,

public function dataLoaded(event:Event):void {

   .. parse event.target.data if needed...

    onLoadDelegate.customLoaderComplete(url, data);

}

, " " / , .

+1

Source: https://habr.com/ru/post/1714099/


All Articles