1 Reply Latest reply on Mar 7, 2010 9:38 PM by toft

    Spark Label event problem

    toft Level 1

      Event handler for a Spark.Label control:

       

      private function onLabelClick(e:MouseEvent):void
      {
      trace(e.target);
      trace(e.target.text);

      }

       

      First trace returns: '[object TextLine]'

       

      Then I get this: ReferenceError: Error #1069: Property text not found on flash.text.engine.TextLine and there is no default value.

       

       

      What is going on here and how to fix it ??

       

      And: is it just me or does anyone else have LOADS of problems dealing with all the new 'improvents' in Flex 4??

      (I have to admit that I find the new spark stuff very confusing)

       

       

       

        • 1. Re: Spark Label event problem
          David_F57 Level 5

          Hi,

           

          Try using currentTarget.

           

          As far as flex 'problems', flex 4 is in beta and as things change this could be considered a problem but its beta which means expect a little confusion

           

          fundamentally the basic stuff still work the same, spark has a bit of a learning curve which is to be expected when a product becomes more powerful.

           

          <?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">

           

          <fx:Script>

          <![CDATA[

          protected function label1_clickHandler(event:MouseEvent):void

          {

          lblResult.text = event.currentTarget.text;

          }

          ]]>

          </fx:Script>

           

          <fx:Declarations>

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

          </fx:Declarations>

          <s:Label x="148" y="85" text="A Label that is clickable" click="label1_clickHandler(event)"/>

          <s:Label id="lblResult" x="148" y="115" text="result"/>

          </s:Application>

          1 person found this helpful