1
votes

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?

1
Are you using Flex components or just the useful utilities included in the Flex framework? If it's the latter, you can grab the appropriate SWC files and use a standard ActionScript project. I'm doing that with a project I am building right now (imported framework.swc, rpc_rb.swc, and rpc.swc for my purposes)Josh

1 Answers

4
votes

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);