Sometimes you need to wrap Flex object with special mx.utils.ObjectProxy wrapper class to listen for property change events. Documentation describes special object_proxy “object” property containing reference to real object. But accessing this property at runtime always returns “null”, althought this property is visible in debuger watch window with “package” icon. Code below demonstrates the problem, and shows “Real object: null” message:
import mx.utils.ObjectProxy;
import mx.controls.Alert;
...
var o1:Object = { f1:"test", f2:123 };
var o2:Object = new ObjectProxy(o1);
var o3:Object = ObjectProxy(o2).object;
Alert.show("Real object: "+o3);
Solution is pretty simple. To access the original object, you need to use special namespaced property and special code handling. Here is a sample:
import mx.utils.ObjectProxy;
import mx.utils.object_proxy;
import mx.controls.Alert;
...
var o1:Object = { f1:"test", f2:123 };
var o2:Object = new ObjectProxy(o1);
var o3:Object = ObjectProxy(o2).object_proxy::object;
Alert.show("Real object: "+o3);

Comments