4 Replies Latest reply on Mar 5, 2012 12:22 AM by Omererer

    I don't see the TexField

    Argosk81

      I don't understand where i wrong.. 

       

      I have this class:

       

       

      package myComponents

      {

                import flash.display.Sprite;

                import flash.events.MouseEvent;

                import flash.text.TextField;

                import flash.text.TextFieldType;

       

                public class TextField_caretIndex extends Sprite

                {

       

                                    public function TextField_caretIndex()

                                    {

                                              var tf:TextField = createCustomTextField(10, 10, 100, 100);

                                              tf.wordWrap = true;

                                              tf.text = "Click in this text field. Compare the difference between clicking without selecting versus clicking and selecting text.";

                                              //tf.addEventListener(MouseEvent.CLICK, printCursorPosition);

                                    }

       

                                    private function createCustomTextField(x:Number, y:Number, width:Number, height:Number):TextField {

                                              var result:TextField = new TextField();

                                              result.x = x;

                                              result.y = y;

                                              result.width = width;

                                              result.height = height;

                                              addChild(result);

                                              return result;

                                    }

       

                }

      }

       

       

      And i call it in this way:

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                                       xmlns:s="library://ns.adobe.com/flex/spark"

                                       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">

                <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

                <fx:Script>

                          <![CDATA[

                                    import myComponents.TextField_caretIndex;

       

                                    public function init():void

                                    {

                                              var lb:TextField_caretIndex = new TextField_caretIndex();

                                    }

                          ]]>

                </fx:Script>

      </s:Application>

       

      But it doesn't works.. I don't see textfield