6 Replies Latest reply on May 31, 2009 8:02 PM by toft

    Annoying Text component.

    toft Level 1

       

      I have a class with a function that dynamicly creates some Text components and sets their properties. This works fine. They turn up where they should.

       

      However, the e.target.x property in the event handler returns 0 for all the Text components. When testing e.target.width and e.target.toString() I get correct, individual values.

       

       

       

      Is this a bug ??

       

       

      Simplified code:

       

       

      private

       

       

       

       

       

      function createLeftBoard():void

      {

       

       

       

       

       

           for(var i:int = 0; i < 6; i++)

           {    

       

       

       

       

       

                var t:Text = new Text();

       

                t.width = _w + i; // adding i to width here for debugging purposes

                t.x = _x;

       

                _x += _w;

                t.addEventListener(MouseEvent.CLICK, assignPoints);

       

       

                addChild(t);

           }

      }

       

       

      // this doesnt work because e.target.x returns 0 for all components:

       

       

      private function assignPoints(e:Event):void

      {

           sh_marker.x = e.target.x;

           sh_marker.visible =

       

       

       

      true;

      }