Sorry for  all the bug spewing here, this is mostly so I can register these things in Google for when I forget them next... That being said, if you see something I'm overlooking, love to know about it as always : ).

So it seems XmlNode's attributes property doesn't derive from object. Specifically it's prototype is undefined, so it can't see things like toString(), or anything else in object.prototype. Man there are so many of these little things with teh Flash API, and each one takes so much time (and special case code, yuck). Well the bright side is our C# (or VB) product won't have these problems - or well I guess they will have them, but also have automatically inserted workarounds, which is almost as good as not having them. Ok, nothing is almost as good as not having them, what am I saying.

That being said, not sure how to “automatically work around” this one. We have some stuff in object prototype that helps with things like foreach in C#. I guess test to see if Xml attributes are being enumerated and send it to a special static method. Yeeuch.

For the record, here is the test:

Object.prototype.xx = 5;
var src = "<?xml version='1.0' ?><!DOCTYPE xxx><test name='boo'><test2>text</test2><test3/></test>";
var x = new XML(src);
trace(x.firstChild.attributes["name"]); // boo
trace("atr: " + x.firstChild.attributes.xx); // undefined
// everything else works... trace(src.xx); // 5 trace(x.xx); // 5 trace(x.childNodes.xx); // 5 trace(x.contentType.xx); // 5 trace(x.docTypeDecl.xx); // 5 trace(x.firstChild.xx); // 5 trace(x.ignoreWhite.xx); // 5 trace(x.lastChild.xx); // 5 trace(x.firstChild.firstChild.nextSibling.xx); // 5 trace(x.firstChild.nodeName.xx); // 5 trace(x.firstChild.nodeType.xx); // 5 trace(x.firstChild.firstChild.firstChild.nodeValue.xx); // 5 trace(x.firstChild.parentNode.xx); // 5 trace(x.firstChild.firstChild.nextSibling.previousSibling.xx); // 5 trace(x.status.xx); // 5 trace(x.xmlDecl.xx); // 5
posted on Thursday, February 24, 2005 6:15 PM
Feedback
  • # RE: Swf bug - Xml.attributes doesn't have a prototype..?
    bokel
    Posted @ 2/24/2005 7:14 PM
    it was always my thinking, that performance was the motivation to kill the prototype of xml attributes. Maybe some MM engineer can elaborate on this. Btw. _global ist another candidate.

    Cheers,
    Ralf.

  • # RE: Swf bug - Xml.attributes doesn't have a prototype..?
    Robin Debreuil
    Posted @ 2/24/2005 7:48 PM
    hey thanks Ralf - I hadn't run into this on _global yet, you probably just saved me a few painful hours... My bet is someone just forgot, hard to imagine performance was the top goal with that class ; ). Well, it does have its work cut out for it I guess...

    At least it still knows how to enumerate itself...

Blog Stats

  • Posts - 121
  • Stories - 1
  • Comments - 1440
  • Trackbacks - 47

.Net Blogs

01101 Blogs

Flash Blogs

Graphics

People