Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在actionscript中缩短数组?_Actionscript - Fatal编程技术网

在actionscript中缩短数组?

在actionscript中缩短数组?,actionscript,Actionscript,我怎样才能缩短代码,有什么办法吗?我觉得重复太多了 var bokstaver1:Array = new Array("a", "b", "c"); var bokstaver2:Array = ["d","e","f"]; var bokstaver:Array = New Array(); bokstaver[0] = "b"; bokstaver[1] = "i"; bokstaver[2] = "l"; bokstaver[3] = "l"; bokstaver

我怎样才能缩短代码,有什么办法吗?我觉得重复太多了

    var bokstaver1:Array = new Array("a", "b", "c");
    var bokstaver2:Array = ["d","e","f"];
    var bokstaver:Array = New Array();

bokstaver[0] = "b";
bokstaver[1] = "i";
bokstaver[2] = "l";
bokstaver[3] = "l";
bokstaver[4] = "e";

我是新来的,所以如果这不是在这里提问的方式,请不要急于侮辱。

你可以用这种简单的方式:

 var bokstaver:Array = "bille".split("");
 trace(bokstaver); // outputs: b,i,l,l,e

您可以通过以下简单方式完成:

 var bokstaver:Array = "bille".split("");
 trace(bokstaver); // outputs: b,i,l,l,e

你的问题很好。但是,你能解释一下bokstaver1和bokstaver2之间的关系吗?为什么你不简单地键入bokstaver=[“b”、“i”、“l”、“l”、“e”]?我的老师是这样教我们的,但看着它,我知道必须有一种更容易格式化的方法。谢谢!跟踪时如何删除逗号?你的问题很好。但是,你能解释一下bokstaver1和bokstaver2之间的关系吗?为什么你不简单地键入bokstaver=[“b”、“i”、“l”、“l”、“e”]?我的老师是这样教我们的,但看着它,我知道必须有一种更容易格式化的方法。谢谢!跟踪时如何删除逗号?如何删除逗号?并将其输出为“bille”bokstaver.join(“”);但是为什么不使用字符串呢?@user3030785就像Arlaud Agbe Pierre刚才说的:
bokstaver.join(“”)如何删除逗号?并将其输出为“bille”bokstaver.join(“”);但是为什么不使用字符串呢?@user3030785就像Arlaud Agbe Pierre刚才说的:
bokstaver.join(“”)