1 Reply Latest reply on Sep 20, 2006 2:18 PM by peterent

    begginers question: can't add textField

    zeroin Level 1


      I am a begginer and I try a simple AS3 application:

      this is HelloWorld.as - actionscript component:

      package {
      import flash.display.Sprite;
      import flash.text.TextField;

      public class HelloWorld extends Sprite {

      public function HelloWorld() {

      var textField:TextField = new TextField();
      textField.text = "Hello, world!";

      trace("Hello, world!");

      and in my mxml application I just have this:

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



      and it doesn't show any text on a screen, however it traces "hello world". Please, help.
        • 1. Re: begginers question: can't add textField
          peterent Level 2
          The problem is that Sprite is too low-level to be considered a Flex component. You should extend mx.core.UIComponent as the basis for any Flex component.

          You can put a Sprite into a UIComponent, but a UIComponent is also a Sprite, you can reference its graphics property and draw into that.

          But if you do go down to UIComponent, you'll need to implement other functions such as measure. It might be a lot easier to just extend an existing control (such as Text).