Raegond
Raegond

Reputation: 13

Shorten array in actionscript?

How can I make this code shorter, is there any way? I feel there's too much repeating..

    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";

I'm all new here so if this is not a way to ask a question on here please don't hasten insults.

Upvotes: 1

Views: 59

Answers (1)

Ivan Chernykh
Ivan Chernykh

Reputation: 42166

You can do it in this easy way:

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

Upvotes: 1

Related Questions