URLLoader doesn’t even try to load. Error #2032: Stream Error

actionscript-3urlloader

I am trying to use URLLoader to load an XML file from server (same domain as swf). This should be too simple but I am getting Error #2032: Stream Error

If I trace the HTTP status event it just shows status=0 though I have read that Mozilla doesn't supply status codes to Flash Player so maybe it's not informative.

I have sniffed the HTTP traffic with Charles and Flash isn't even trying to load the url – no request is made, so it doesn't even fail.

I can browse to the url, which is on an internal url that looks like: http://media.project:8080/audio/playlist.xml

I have tried putting a crossdomain.xml in there (with and without a to-ports="8080"), though it shouldn't need one.

Neither the onOpen nor onActivate events fire, just one HTTPStatus and then the IOError.

I have copied the common URLLoader code from Adobe example, mine looks like this:

    public class PlaylistLoader extends EventDispatcher
{
    public var xmlLoader:URLLoader;
    public var url:String = '';

    public function PlaylistLoader(url:String)
    {
        url = url;
        trace(url);
        xmlLoader = new URLLoader();
        xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
        xmlLoader.addEventListener(Event.COMPLETE, onResult);
        xmlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
        xmlLoader.addEventListener(Event.OPEN, onOpen);
        xmlLoader.addEventListener(Event.ACTIVATE, onActivate);
    }

    public function loadData():void {
        var req:URLRequest = new URLRequest(url);
        trace(req);
        xmlLoader.load(req);
    }

    protected function onResult(e:Event):void
    {
        var xmlData:XML = e.target.data as XML;
        parseData(xmlData);
    }

    private function httpStatusHandler(event:HTTPStatusEvent):void {
        trace("httpStatusHandler: " + event);
    }

    protected function onOpen(e:Event):void
    {
        trace(e);
    }

    protected function onActivate(e:Event):void
    {
        trace(e);
    }

    protected function onIOError(e:IOErrorEvent):void
    {
        trace(e);
    }

Best Answer

url = url;

in the constructor sets the local url to the local url. If you want to save that value inside of the object, you need to reference the object member url explicitely (or use a different name):

this.url = url;
Related Topic