Try this:

if (a instanceof Array) {
        var n:Array = a.slice();
        doMyArrayFunction(n);
}


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Danny
Kodicek
Sent: Friday, July 20, 2007 9:04 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Casting to Array

I'm trying to do something like this:

if (a instanceof Array) {
doMyArrayFunction(a)
}

the doMyArrayFunction expects an Array object, so this throws an error. What
I would normally do in this case is cast the object to the class I'm
expecting, but unfortunately Array(a) doesn't leave a unchanged, as it would
with most classes, but returns [a] - the array gets nested.

Anyone have a suggestion as to how I can get around this? The only thing I
can think of is Array(a)[0], which seems a bit stupid.

(I'm in AS2)

Danny

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to