2 Replies Latest reply on Jun 11, 2009 4:32 AM by gag_sam

    Interface / DisplayObject

    MarkMeTo

      Hello,

       

      I've created an interface which contains a couple of functions.

       

      I've also created a couple of GUI components (both of which extend Canvas) which implement the interface.

       

      When I try and add the GUI components to a parent Canvas object (using "parentCanvas.addChild(myGUIComponent);"), I get the following error:

       

      "Implicit coercion of a value of type <MyInterface> to an unrelated type flash.display:DisplayObject."

       

      I can understand why it's doing it but don't know how to get around the problem. I've tried getting my interface to extend IUIComponent but it doesn't solve it.

       

      Thanks for any thoughts.

        • 1. Re: Interface / DisplayObject
          MarkMeTo Level 1

          This works:

           

          parentCanvas.addChild(myGUIComponent as DisplayObject);

          • 2. Re: Interface / DisplayObject
            gag_sam

            Well, what I understood that you have created a custom component which extends Canvas and implements a self created interface. When you try to add it to another Canvas, it’s throwing an error saying “Implicit coercion of a value of type <MyInterface> to an unrelated type flash.display:DisplayObject”. I don’t know why you are getting this error as I implemented the same in one of my project but it worked for me. Can you please explain it more?