Weird Loader event error after declaring RSS XML namespace

Can`t really get my head around this, I`ve used a code snippet from an Adobe RSS reader example to sort the namespace of an RSS feed:

if (rssXML.namespace("") != undefined)
{
default xml namespace = rssXML.namespace("");
}

Then tried to load an image using a URL from it with a listener for load completion:

var ldr:Loader = new Loader()
var url:String = item.enclosure.@url;
var urlReq:URLRequest = new URLRequest(url);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete)
ldr.load(urlReq);
contentHolder.addChild(ldr);>
public function onLoadComplete(event:Event):void
{
	trace(event)
}

But this kept on throwing me an annoying error:

ReferenceError: Error #1069: Property namespace not found on flash.events.Event and there is no default value.

Only solution was commenting out the namespace bit. It might work with a different namespace declaration, but not with this, so beware :)


2 Responses to “Weird Loader event error after declaring RSS XML namespace”

  • zen Says:

    you need to read the variable once its been set…

    01.var ldr:Loader = new Loader()
    02.var url:String;
    03.var urlReq:URLRequest = new URLRequest(url);
    04.ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete)
    05.ldr.load(urlReq);
    06.contentHolder.addChild(ldr);>
    07.public function onLoadComplete(event:Event):void
    08.{

    url = item.enclosure.@url;

    10.}

    and im not sure why you are adding ldr to stage…

    good luck!

    _z

  • zen Says:

    gah, my comment got borked by your syntax catcher :(

    basically, on the onComplete event for the xml, you can parse down to the string with the

    var url:String = String( item.enclosure.url );

    for using custom namespaces, you have to declare the namespace upfront like

    var xmlNs:Namespace = new Namespace(“http://www.attila.com/uri/”)

    or just bypass it altogether :

    var attributes:XMLList = XML(event.result).*::enclosure.*::url;

    or use a regex to strip it in the event ;)

    check out :
    http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000130.html

Leave a Reply