3 Replies Latest reply on Jul 26, 2007 10:47 AM by Peter deHaan

    Flex Component Kit for Flash CS3

    JD2512
      Hi,

      I created a flex component using the component kit for Flash CS3. The component contains a vector image wrapped as a MovieClip.
      In my flex application I add the component as child to a Canvas. It works well if i add it like -

      <mx:Canvas id="container" >
      <local:MyComponent />
      </mx:Canvas>

      or like -

      container.addChild (new MyComponent()); //DISPLAYED

      However, the component is not displayed when I do the following -

      var array:Array = new Array(new MyComponent());
      container.addChild(array[0]); //NOT DISPLAYED

      Can somebody tell me why this is so?
      I would also like to know if such components can be instantiated using flash.utils.getDefinitionByName.
      I tried it but I get Error #1065: Variable 'componentName' is not defined

      Could somebody please tell me what is going on?
        • 1. Re: Flex Component Kit for Flash CS3
          bolaughlin Level 1

          Hi -

          The issue of container.addChild (array[0]), I think if you kick the container a little, by calling LayoutManager's validateNow() function, it will display as you expect.

          For your second question, I don't fully understand how you arrived at Error 1065. Could you post more code to show what you're doing?

          Thanks.
          • 2. Re: Flex Component Kit for Flash CS3
            JD2512 Level 1
            Hi bolaughlin,

            Thanks for you reply.

            Error 1065:

            import MyComponent;

            var comp:MyComponent = new MyComponent(); //Error 1065
            //Where MyComponent is the Flash CS3 clip that was converted to Flex component

            I have a workaround for this -

            I first add the component as an Mxml tag with visibility false and then remove the component
            with actionscript. Now all instantiations work normally (this includes all components in the SWC).

            <mx:Canvas id="container" >
            <local:MyComponent visible="false" />
            </mx:Canvas>

            and in <mx:Script>

            container.removeAllChildren();
            var comp:MyComponent = new MyComponent(); //Works
            var anotherComp:MyOtherComponent = new MyOtherComponent();
            //From the same swc; This also works.

            I have a feeling this problem is similar to the 'shared fonts' problem that
            existed with Flash MX and below.

            Anyway, even though I don't really know whats happening, my project can
            move ahead. Hopefully some Guru will explain this.

            Until then...thank you very much.
            • 3. Re: Flex Component Kit for Flash CS3
              Peter deHaan Level 4
              JD2512,

              Do you know what version of the Flash/Flex Component Kit you are using (1.0.0, 1.1.0)? And which version of the SDK are you running? Was it the Labs beta 1 release, or have you tried installing a newer nightly build?

              There have been a lot of changes/fixes/improvements in the Component Kit since its first release and you may want to install the latest copy of the SDK/MXP and try your code. What you're seeing doesnt sound quite right.

              If you still see the same behavior after updating the SDK and Component Kit, please file a bug in the bugbase ( http://bugs.adobe.com/flex/ -- and please include your source files -- MXML and FLA/SWF) and post the bug number here so I can track the issue.

              Thanks,

              Peter