在AS3调用Firebug的console时被雷了

Posted on March 19, 2009 by Fdream

写了这么一段as3的代码,用到了E4X,Firebug是自己写的一个用来调用Firebug的console的调试类:

var x:XML = evt.message as XML;
Firebug.info(x.toString()); // 正常输出XML内容
Firebug.info(x is XML);     // true
Firebug.info(x.@status);    // 没有输出,但的确是有这个属性的

莫名奇妙,不知道啥原因,翻了手册,也Google了,还是不知道啥原因。于是想想这样一试:

var x:XML = evt.message as XML;
var status:String = x.@status;
Firebug.info(x.toString()); // 正常输出XML内容
Firebug.info(x is XML);     // true
Firebug.info(status);       // 成功输出status属性的值“success”

真让人崩溃!为什么一开始的写法就不能输出呢?不懂,有明白的人指点下吧,谢谢!

分享 |
Categories:
Flash/AS
Tags:
,
Comments:
2 Comments
Views:
1,457 Views

Related Posts

2 Responses to <在AS3调用Firebug的console时被雷了>

  1. Flykye says:

    Firebug.info(x.@status);
    把x.@status转换为String就可以,因为@status是Object,貌似不会自动调用默认的toString()方法,所以要手工转换为String才有输出。
    Firebug.info(String(x.@status));

  2. Fdream says:

    呵呵,谢谢^_^

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>