views:

77

answers:

2

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);
    }
A: 

it seems url string still empty

public var url:String = '';

isn't it?

try

public var url:String = 'http://media.project:8080/audio/playlist.xml';
agil
yes, for the reason described by poke below
Anentropic
+1  A: 
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;
poke
Jeepers, you're right!
Anentropic
I could have sworn I've written code like that before and it worked fine, but obviously not...
Anentropic