6 Replies Latest reply on May 4, 2011 12:39 AM by pgpradeep

    Error #1034: Type Coercion failed: Error

    pgpradeep Level 1

      Hi,

       

      I am using ActionScript 3.0.

      Here I want to setFocus on a DisplayObject(flash.display.DisplayObject).

       

      I tried :

       

                          //var dispObject:DisplayObject;

                          //dispObject = code here to get displayObject;//valid DisplayObject got

                          var focusManager1:FocusManager = dispObject["focusManager"];
                          var component:IFocusManagerComponent = dispObject as IFocusManagerComponent;
                          if(focusManager1 != null && component != null)
                          {
                              focusManager1.setFocus(component);
                          }

       

      But I am getting : Error #1034: Type Coercion failed: cannot convert mx.managers::FocusManager@3881e41 to mx.managers.FocusManager.

      This is at line :  var focusManager1:FocusManager = dispObject["focusManager"];

       

      The same code would work if I use mx.core.UIComponent instead of DisplayObject, I guess.

      But I am not able to convert DisplayObject to UIComponent (invalid cast).

       

      Can someone please help me.

       

      Thanks,

      Pradeep.