views:

217

answers:

1

Hi,

I'm kinda new to Flex. I have trying to send Hash from Ruby on Rails application to Flex using RubyAMF.

Results look like this:

result (mx.utils.ObjectProxy (@22b207d9))
|
|-->errors (object (@16c64dd1))
     |-> Name -----"Name is too short"
     |-> Email-----"Email has already been taken"
     |-> Password--"Password is too short"

Which is What I wanted as I'm passing validation error messages back. I'm not sure though how to read the children of 'errors' as I don't know what they can be (so I can call errors.Name for instance) and the fact that 'errors' is being returned back as an 'object' without specific type I couldn't cast it to an Array or such in Flex to use it.

Any ideas how I can get the children of 'errors'?

Thanks,

Tam

+2  A: 

You can get dynamic properties like this:

var property:String;
var errors:Object = result.errors;
for (property in errors)
{
    trace(errors[property]);
}

An untyped Object can be iterated over using a 'for in' loop, giving you all of the properties/methods attached to the object, so you don't need to know them beforehand.

viatropos