0

我在 flash builder 中创建了 flash 项目和一个 flash 组件项目,然后在 flex 组件项目中创建了一个 spark 组件。当我尝试在 Flash 中添加自定义组件时,它抛出错误

//code
this.addChild(new TestComp);
//compilation error
1067: Implicit coercion of a value of type TestComp to an unrelated type flash.display:DisplayObject.   Main.as /pw3d/src   line 35 Flex Problem

是否可以在 Flash 中使用 flex 组件?有解决办法吗?

4

1 回答 1

1

Is it possible to use flex components in flash at all?

Yes, it is possible, in theory, but I expect it to be tedious and difficult. You'll have to do all your framework initialization manually. That means you'll have to do things like setup the SystemManager class manually.

Honestly, I don't know everything that the Flex Compiler / Application tag does to setup the Flex Framework. You may have to compile a simple Flex app with the 'keep' attribute and review the generated code to make sure you mimic that in your Flash Pro code.

Some reference information can be found here, here, and here.

The error you're seeing is odd; because a Flex Component must extend UIComponent and UIComponent extends DisplayObject. I wonder if you are missing a SWC library in your class path somehow and Flash pro is unable to tell that TestComp is actually a DisplayObject.

于 2012-10-17T13:32:55.233 回答