Is there a test to see if an Object is an associative array?
Thanks.
Is there a test to see if an Object is an associative array?
Thanks.
When using an Object as an associative array, you are simply adding dynamic properties to it, with arbitrary values.
for...in loops iterate over only dynamic properties of an Object, so if you create a for...in loop and it completes one loop, you will know that the Object is an associative array.
http://livedocs.adobe.com/flex/3/langref/statements.html#for..in
function isObjectAssociativeArray(obj:Object):Boolean
{
for (var prop in obj)
{
return true;
}
return false;
}
You can try getQualifiedClassName and see if the return type is "Object". I haven't tested this myself, but it accepts flash primitives (Object, Array, String...) as well as Classes.