Welcome

Thanks for dropping by! Feel free to join the discussion by leaving comments, and stay updated by subscribing to the RSS feed. See ya around!

Categories

Tag Cloud

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Unwrap ObjectProxy to access real object

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);
Share this:
  • Print this article!
  • Digg
  • Reddit
  • Facebook
  • del.icio.us
  • TwitThis
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • StumbleUpon

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>