Here is a little example... watch the control walk the walk while you are typing...

 

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

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>

            <![CDATA[

                  import flash.events.Event;

                 

                  public function myChangeHandler (e:Event) : void

                  {

                        e.currentTarget.x +=10;

                  }

            ]]>

      </mx:Script>

      <mx:TextInput x="27" y="27" text=""  change="myChangeHandler(event)"/>

</mx:Application>

 

 

From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Mark Piller
Sent: Saturday, November 04, 2006 6:18 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] refering to an MXML element in an event handler

 

Suppose I have the following MXML declaration:

<mx:Canvas id="id0" x="37" y="41" >
<mx:Text x="25" y="10" text="Some Text" added="addLabel(this)" />
</mx:Canvas>

Notice in the "added" handler I use "this" hoping that the scope of
"this" is the actual Text element. My thinking is incorrect and the
debugger shows that "this" refers to the top level container (the one
defined in the same MXML page). So my question is: is there a way to
refer to that Text element *without* assigning an id to it. I assume
the following would work, but it is really not ideal for my use-case:

<mx:Canvas id="id0" x="37" y="41" >
<mx:Text id="myText" x="25" y="10" text="Some Text"
added="addLabel(myText)" />
</mx:Canvas>

Thanks,
Mark

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to