开发者

e4x newb woes - attribute trace

开发者 https://www.devze.com 2023-03-23 16:01 出处:网络
Sorry if I\'m doing anything really dumb, but could anybody see anything immediately wrong with the following?

Sorry if I'm doing anything really dumb, but could anybody see anything immediately wrong with the following?

var layout = new XML()

layout=
<layout color="red">
</layout>

function init()
{ 
post(layout.@color);
}

it returns what I assume to be a ram address rat开发者_高级运维her than the value.

In the event that the software in question wants an object of type string, what is the best way to enforce that? I doubt thats the cas, but am willing to try


A string cast should work fine, e.g.:

trace(String(layout.@color));

Note that in your example there's no need to assign a new XML object to layout, since you overwrite it with the next assignment one line later.

This article is highly useful if you're just getting started with E4X.

0

精彩评论

暂无评论...
验证码 换一张
取 消