向 ActionScript 变量添加多个类别

发布于 2024-12-20 23:31:26 字数 330 浏览 1 评论 0 原文

我是一名设计师,试图为 Web 项目修改一些 ActionScript。在定义变量时,我希望其中一些变量具有多个参数/类别(我为我缺乏词汇而道歉)。

例如...

var Projects= [
{myName:"Example1",myType:"OldProject",myCopy:"Coming soon."}    
// etc

];

如何包含多个参数,例如,myType 可以同时设置为 OldProject2005Project

感谢您的帮助!

I am a designer trying to modify some ActionScript for a web project. When defining the variables, I would like for some of them to have multiple parameters/categories (I apologize for my lack of vocabulary).

For example...

var Projects= [
{myName:"Example1",myType:"OldProject",myCopy:"Coming soon."}    
// etc

];

How can I include multiple parameters so, for example, myType could be set to OldProject and 2005Project at the same time?

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖伴 2024-12-27 23:31:26

您可以将 myType 参数设置为字符串数组,而不仅仅是一个。

然后您可以循环访问它们以查找所有 types 值。

像这样的东西:

var Projects= [
{myName:"Example1",types:["OldProject", "2005Project"],myCopy:"Coming soon."}
];

for (int i = 0; i < Projects[0].types.length; i++) {
    // access them with Projects[0].types[i]
}

You can set the myType parameter to be an array of strings instead of just one.

then you can access them in a loop to find all of the types values.

something like this:

var Projects= [
{myName:"Example1",types:["OldProject", "2005Project"],myCopy:"Coming soon."}
];

for (int i = 0; i < Projects[0].types.length; i++) {
    // access them with Projects[0].types[i]
}
江湖彼岸 2024-12-27 23:31:26

一些选项包括:

//1. JSON like object option
var projects:Object = {myName:"Example1",myType:"OldProject",myCopy:"Coming soon."};
trace(projects.myName + projects.myType + "etc..."); //Access it

//2. Dicitonary option
import flash.utils.Dictionary;
var d:Dictionary = new Dictionary();
d["myName"] = "Example1"; //Set values like this
trace(d["myName"]); //Access them like this

还有一个关联数组、一个自定义类等...,但我会向您推荐选项 1,特别是如果您更多的是设计师而不是程序员。

如果您想要“堆栈属性”,您可以将 myType 设置为数组或另一个对象,例如:

obj.myType = {one:"OldProject", two: "2005Project"};
trace(obj.myType.one + obj.myType.two);

obj.myType = new Array();
obj.myType[0] = "OldProject";
obj.myType[1] = "2005Project";
trace(obj.myType[0], obj.myType[1]); //Access them

Some of the options include:

//1. JSON like object option
var projects:Object = {myName:"Example1",myType:"OldProject",myCopy:"Coming soon."};
trace(projects.myName + projects.myType + "etc..."); //Access it

//2. Dicitonary option
import flash.utils.Dictionary;
var d:Dictionary = new Dictionary();
d["myName"] = "Example1"; //Set values like this
trace(d["myName"]); //Access them like this

There's also an associative array, a custom class, etc..., but I would recommend option 1 for you especially if you are more designer than programmer.

If you wanted to "Stack properties you can set myType to an array or another object, something like:

obj.myType = {one:"OldProject", two: "2005Project"};
trace(obj.myType.one + obj.myType.two);

or

obj.myType = new Array();
obj.myType[0] = "OldProject";
obj.myType[1] = "2005Project";
trace(obj.myType[0], obj.myType[1]); //Access them
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文