var a1:Array = ["a", "b", "c"];
var a2:Array = ["c", "b", "x", "y"];
var a3:Array = ["a", "x", "x", "y", "z"];

var c:Array = arrConcatUnique(a1, a2, a3); // result: ["a", "b", "c", "x", "y", 
"z"]

private function arrConcatUnique(...args):Array
{
    var retArr:Array = new Array();
    for each (var arg:* in args)
    {
        if (arg is Array)
        {
            for each (var value:* in arg)
            {
                if (retArr.indexOf(value) == -1)
                    retArr.push(value);
            }
        }
    }
    return retArr;
}

// from as3corelib:
import com.adobe.utils.ArrayUtil;

var a1:Array = ["a", "b", "c"];
var a2:Array = ["c", "b", "x", "y"];

var c:Array = ArrayUtil.createUniqueCopy(a1.concat(a2)); // result: ["a", "b", 
"c", "x", "y"]

---------------------    Privileged/Confidential Information may be contained 
in this message. If you are not the addressee indicated in this message (or 
responsible for delivery of the message to such person), you may not copy or 
deliver this message to anyone. In such a case, you should destroy this message 
and kindly notify the sender by reply e-mail.

--- On Fri, 9/3/10, Lehr, Theodore <ted_l...@federal.dell.com> wrote:

From: Lehr, Theodore <ted_l...@federal.dell.com>
Subject: [Flashcoders] parsing multi-dimensional array
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Date: Friday, September 3, 2010, 10:35 PM

so if I have a multi-dimensional array - how could I break them into their own 
array? So if I have:

arr[0] = ["red",0,0];
arr[1] = ["red",1,0];
arr[2] = ["red",2,0];
arr[3] = ["blue",0,0];
arr[4] = ["blue",1,0];
arr[5] = ["blue",2,0];

What I need to do is break red into it's own array and blue into it's own array 
- and there could be any number of colors....

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to