3 Replies Latest reply on Oct 25, 2007 8:01 PM by ntsiii

    Problems with addChild in UIComponent

    Thiago Ricieri
      Hello there

      I have this class, which extends UIComponent class, and I need put a Label inside it, but when I create the label, and add it using addChild method, the Label isnt shown.

      The class name is "Page" and it is child of a class named "PageManager" (extends UIComponeny) which is a child of another class named "Magazine" (extends UIComponent) which is a unique child of "Application" (extends Canvas).

      the class source-code:

      /**
      * Página que carrega o conteúdo passado por XML e é dinâmica
      *
      * @author Thiago Ricieri
      * @version 1.0
      */

      package sm.display {

      //Importação de classes do Library do Flash
      import flash.display.Loader;
      import flash.events.Event;
      import flash.events.MouseEvent;
      import flash.net.URLRequest;

      import mx.containers.HBox;
      import mx.controls.Label;
      import mx.core.UIComponent;

      /**
      * Classe que define o documento que inicializa a revista
      */
      public class Page extends UIComponent {

      /**
      * Atributos
      */
      public var pageSide:Number;
      public var isBehind:Boolean;
      private var infoLabel:Label;

      static public var numInstances:Number = 0;

      /**
      * Construtor da Classe
      */
      public function Page() {
      super();
      infoLabel = new Label();
      this.addChild(infoLabel);
      infoLabel.text = "some text here " + numInstances.toString();
      infoLabel.setStyle("color", "#ffffff");
      infoLabel.y=150;
      infoLabel.x=150;
      numInstances++;
      pageSide = 0;
      isBehind = false;
      this.addEventListener(MouseEvent.CLICK, clickHandle);
      }

      public function loadImage(src:String):void {
      var _loader:Loader = new Loader();
      _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandle);
      var request:URLRequest = new URLRequest(src);
      _loader.load(request);
      //addChild(_loader);
      }

      private function completeHandle(e:Event):void{

      }

      protected function clickHandle(e:Event):void {

      }
      }
      }


      Thanks a lot ;]