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,

Im trying to translate an mxml binding tag to actionscript :

I got this mxml tag:

<mx:Binding source="model.podManager.getPod( mypodId ).destroy"
destination="handleDestroy" />

and its setter function :

private function set handleDestroy( destroy:Boolean ): void {
// some code
}

This works 100%. Im now trying to implement this binding in
actionscript. I have tried things like:

BindingUtils.bindSetter( handleDestroy, model.podManager.getPod(
mypodId ), "destroy", false );

and the setter function defined identically and it doesnt compile.
It complains about the "set" in the setter function. Removing
the "set" keyword makes it compile but the binding never fires and
the function is never executed.
What am I doing wrong? How can I make this work? Is there any
working example on implementing a binding to setter function in
actionscript ?

I need expert help :)

Thank you all in advance.

__._,_.___

--
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
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to