I actually figured this out right after I asked but I did it a different way.

It does basically the same thing though.

 

Here is an example:

 

<!—My application page (TestApp.mxml)-- >

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

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

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns:Weee="*" initialize="SetVar()">

<mx:Script>

<![CDATA[

function SetVar(){

MyTest.MyValue = "Rararararar";

}

]]>

</mx:Script>

<Weee:MyTestComp id="MyTest" />

</mx:Application>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

<!—My component file (MyTestComp.mxml)-->

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

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

<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml" width="400" height="400">

<mx:Script>

<![CDATA[

var MyValue:String = "BlahBlah"

function set MyOtherValue(NewValue):Void {

mx.core.Application.alert('The new value is: '+MyValue);

}

]]>

</mx:Script>

<mx:Binding source="MyValue" destination="MyOtherValue" />

</mx:VBox>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------



 







>From: Manish Jethani <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: Re: [flexcoders] Event Handlers inside custom components
>Date: Thu, 28 Jul 2005 23:12:51 +0530
>
>On 7/28/05, Archibald Scatflinger <[EMAIL PROTECTED]> wrote:
>
> > I do not want to use implicit getter/setters because I want the
> > components property to be bindable.
>
>To make the component's property bindable, specify a "ChangeEvent" for
>the property and dispatch the event when the value changes.
>
>e.g.
>
><?xml version="1.0"?>
><mx:Box xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
> <mx:Label text="{labelText}" />
> <mx:Script>
>
> // Storage for 'labelText' property
> private var _labelText:String = "";
>
> [ChangeEvent("labelTextChange")]
> public function get labelText():String
> {
> return _labelText;
> }
> public function set labelText(value:String):Void
> {
> if (value != _labelText)
> {
> _labelText = value;
> dispatchEvent({type: "labelTextChange"});
> }
> }
> </mx:Script>
></mx:Box>
>
>When labelText is modified, the component dispatches an event to
>trigger binding. Check out the generated AS to see how this works.
>
>Manish


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




YAHOO! GROUPS LINKS




Reply via email to