gpt4 book ai didi

actionscript-3 - 基于 interator AS3 设置 XML .@

转载 作者:行者123 更新时间:2023-12-04 04:32:24 25 4
gpt4 key购买 nike

在 AS3 中是否可以导出相同变量的多次迭代,如下例所示:

var item:String = "obj";
var child:XML = new XML(<{item}/>);
child.@x = String(object.x);
child.@y = String(object.y);
child.@n = String(object.name);
child.@w = String(object.width);
child.@h = String(object.height);

//...instead of:
child.@s = String(object.sprite);

//...is the below possible:
for (i = 0; i < <length>; ++i) {
child.@s[i] = String(object.get_sprite(i));
}

//...desired <filename>.xml output:
obj.s0 = "sprite_0"
obj.s1 = "sprite_1"
obj.s2 = "sprite_2"
obj.s3 = "sprite_3"
etc..

最佳答案

有一段时间没有在 AS3 上工作了,但如果我没记错的话,你应该能够做到:

for (i = 0; i < <length>; ++i) {
var attrName = "s" + i.toString();
child.@[attrName] = String(object.get_sprite(i));
}

抱歉,我没有可供自己试用的工具,但应该可以使用。

关于actionscript-3 - 基于 interator AS3 设置 XML .@<index>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52994876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com