Apache – How to create a Flex Display component in Flash

apache-flexcomponentsflashflash-cs3flex3

I have used Flash to make skins, which I import and apply to Flex components.

But how can I create a component in Flash, with properties and methods. And make it able to be added to the displayList in a Flex app?

I installed the Flex component kit for flash. Created my component in flash (it extends MovieClip). Did Command->Convert to flex Component, did File->Published, which gave me a .swc, dropped the .sec file into my Flex project. Now when I create a new var the class "FlashFlexComponentTest" pops up in the new class hint box, so flex sees it. But afterwards I get the error:

Type was not found or was not a
compile-time constant: FlashFlexComponentTest

I feel like I must be missing a step?

Thanks!

UPDATE

I added the .swc via project build path -> add SWC.
I no longer have a compile-time error but I am getting a runtime error:

Type Coercion failed: cannot convert FlashFlexClassTest@9089129 to mx.core.IUIComponent

Best Answer

The base class for all flex components, UIComponent, allows you to add Sprites that don't implement the IUIComponent interface.

An example :

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    creationComplete="init();">

  <mx:Script>
    <![CDATA[

        private function init():void 
        {
            var component:FlashFlexClassTest = new FlashFlexClassTest();
            container.addChild(component);
        }

     ]]>
  </mx:Script>
  <mx:UIComponent id="container" width="100%" height="100%"/>
</mx:Application>
Related Topic