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.
parentCanvas.addChild(myGUIComponent as DisplayObject);
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?