3 Replies Latest reply on Dec 12, 2011 1:29 AM by Claudiu Ursica

    Unable to Cast a Object into Typed Class

    Abhinav Sharma Level 2

      Hi, I am not able to cast a simple object in typed class.

       

      I have a class ItemVO.as

       

      package
      {
          public class ItemVO
          {
              public var idData:String;
              public var valData:String;
          }
      }
      
      In application on some action 
      
      
                  var obj:Object = new Object;
                  obj['idData']="001";
                  obj['valData']="abhinav";
                  try{
                      var itemVO:ItemVO=ItemVO(obj);
                  }catch(e:Error)
                  {
                      Alert.show(e.message);
                  }
      
      

       

      I am getting below error at var itemVO:ItemVO=ItemVO(obj)

      Error #1034: Type Coercion failed: cannot convert Object@b5c3ad9 to ItemVO.

       

      Where I am doing wrong??

       

      Please help.

       

      Thanks.

      Abhinav