简体   繁体   English

AS3共享对象作为变量

[英]AS3 Shared Object as a Variable

I'm sure this is a very basic question, but I'm just wondering if it's possible to create shared object and name it after a string variable. 我确定这是一个非常基本的问题,但是我只是想知道是否可以创建共享库并以字符串变量命名。

For Example: 例如:

var newvariable:Number = 0;

so.data.newvariable.toString(); = ??

Now I know that with the above example /\\ there are easier ways around it, but I really need to find out alternative methods so I can actually name the shared object after the variable. 现在,我知道使用上面的示例/ \\可以找到更简单的方法,但是我确实需要找出替代方法,以便实际上可以在变量之后命名共享库。 Really appreciate this! 真的很感激!

You can use array access brackets to create dynamic property names from variables: 您可以使用数组访问括号从变量创建动态属性名称:

var count:int = 0;
so.data["newvariable" + count] = "foo";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM