Another Flex bug

This one gave me a huge headache: Flex sometimes cannot extract parts of the AMF response - like sub-objects.

This is because you got to have the instance of the sub-object instantiated in your app before the call.

This isn't a compile-time issue as I thought  (like Flex didn't embed the object's class definition) but a runtime issue. If I load this sub-object as root object via another method call, the problematic method starts working.

The solution is to instantiate a single instance of the class before the first AMF service call. Here is the Cairngorm command example:

public class MyCommand implements ICommand, IResponder
{
    private static var _dummy:MyDto;
   
    public function execute(event:CairngormEvent):void
    {
        if (!_dummy)
            _dummy = new MyDto(); // this solves the bug when Flex can't recognize the AMF response
       
        // do the delegate call...
    }
   
    public function result(event:Object): void
    {           
        trace("MyCommand -> result");
       
        // do the result processing...
    }
}