1 Reply Latest reply on Nov 20, 2007 2:06 AM by Sreenivas R

    An AS component doesn't appear in a flex app

    Isaac Fung
      The following AS draws a line and works in its own right,

      package components {

      import flash.display.Sprite;
      import flash.display.Shape;

      public class DrawTest1 extends Sprite {

      public function DrawTest1() {

      var shape:Shape = new Shape();
      shape.graphics.lineStyle(0,0x0000FF, 1);
      shape.graphics.lineTo(100,100);
      addChild(shape);
      }
      }
      }

      It was then included in a flex app as

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      xmlns:custom="components.*"
      layout="horizontal">

      <custom:DrawTest1 />

      </mx:Application>

      but only a blank screen (i.e. without the line) was displayed when the flex app was executed (no error message was given during compilation). Please help.
        • 1. Re: An AS component doesn't appear in a flex app
          Sreenivas R Adobe Employee
          Flex containers (incluing Application) can contain only components which are derived from UIComponent or implement IUIComponent interface.

          To get your component to display in the application create a UIComponent as child and add the DrawTest1 component as a child to it.

          <mx:UIComponent id="p1" creationComplete="p1.addChild(t1)"/>
          <custom:DrawTest1 id="t1"/>