Reputation: 1315
So I'm using Flex to access some of the useful libraries included, but I don't want to deal with the MXML stuff. So I'm writing it all in pure AS3.
Basically, I'm loading the main AS3 class with this MXML:
<?xml version="1.0" encoding="utf-8"?>
<local:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:local="asset.*" />
Now from there, the AS3 takes over and does all its stuff. However, when I try to draw something to my main Canvas
class (which just extends Application) by using the addChild() method, It throws this error:
Type Coercion failed: cannot convert MyObject to mx.core.IUIComponent.
I have also tried adding it directly to the Canvas
object's stage
, but it's null.
Any suggestions?
Upvotes: 1
Views: 94
Reputation: 13532
You can wrap your object in a UIComponent
assuming MyObject
is a subclass of DisplayObject
.
var uicomponent:UIComponent = new UIComponent();
uicomponent.addChild(yourObject);
canvas.addChild(uiComponent);
Upvotes: 4