1 Reply Latest reply on Mar 4, 2011 6:48 AM by UbuntuPenguin

    Custom item renderer problem when casting 'data' object




      I have a strange problem in my custom item renderer class. I`m using amfphp to get typed data from the server. Since i`m using module loader, when user clicks a button, the module A is loaded, connection to the server is established and i get the typed array which servers as a data provider for DataGroup in module A (amfphp performs class mappings).


      Then, in item renderer, i cast data object as its true type, for example class Worker.



      private var vo:Worker;

      protected function itemrenderer1_creationCompleteHandler(event:FlexEvent):void


      vo = data as Worker;



      and use it in item renderer UI controls:


      <s:Label text="{vo.name}" styleName="MenuHeader" />


      First time the module is loaded, everything works fine and i do get vo as class of type Worker. But, when i unload the module and load it again, i do get the data from the server, and i do get the data to the item renderer (object data is not null, and it has all values correctly), but when i try to cast data as Worker, vo is null!


      I have a workaround - not to cast data object as Worker and to use it as dynamic object, but i would like to know what is going on!


      Any idea would be appreciated.