Hi,
bindSetter() might not be the best name of that method. It
could really be called bindFunction() because you are specifying a function to
be called, not a real set method. If you have a real set method, use
bindPropety() and specify the property name defined by the set method. You can
see examples here:
http://livedocs.macromedia.com/flex/2/docs/00001043.html
http://livedocs.macromedia.com/flex/2/docs/00001044.html Here's an example using bindSetter():
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script>
<![CDATA[ import
mx.binding.utils.*;
import mx.events.FlexEvent; <!-- Event listener to configure
binding with a setter. -->
public function mySetterBindingInline(event:FlexEvent):void { var watcherSetter:ChangeWatcher = BindingUtils.bindSetter(function(v:String):void { taSetter1.text = v}, tiSetter1, "text"); } // Set method. public function setMyString(val:String):void { taSetter2.text = val; } <!-- Event listener to configure binding with a setter. --> public function mySetterBinding(event:FlexEvent):void { var watcherSetter:ChangeWatcher = BindingUtils.bindSetter(setMyString, tiSetter2, "text"); } ]]> </mx:Script> <mx:Panel title="My Application" paddingTop="10"
paddingBottom="10"
paddingLeft="10" paddingRight="10" > <mx:Label text="Bind Setter using inline
setter"/>
<mx:TextInput id="tiSetter1" text="Hello Setter" /> <mx:TextArea id="taSetter1" initialize="mySetterBindingInline(event);"/> <mx:Label text="Bind Setter using setter
method"/>
<mx:TextInput id="tiSetter2" text="Hello Setter" /> <mx:TextArea id="taSetter2" initialize="mySetterBinding(event);"/> </mx:Panel> </mx:Application> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Sent: Wednesday, July 19, 2006 5:45 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Flex2: Binding from actionscript Hi all, -- 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
YAHOO! GROUPS LINKS
|