override the set data function in your item renderer and bind your function getter to an event you dispatch in there.
On Dec 27, 2007 2:39 AM, yigit <[EMAIL PROTECTED]> wrote: > i think i'm misunderstood; because your solution suggestions does not > fit my problem. > first of all, functions can be binded. (with an event driven architecture > that triggers > the function to be executed and all bindable references be updated) > to see how it is done, take a look at the article in flex api : > > http://127.0.0.1:64744/help/index.jsp?topic=/com.adobe.flexbuilder.help/html/databinding_4.html > (or search for "[Bindable] function" then click the second result) > > after this quick information, i want to refigure my problem. > assume: myInstance:MyClass; //MyClass implements a bindable toString > method > > my problem has two parts: > 1st; when i use function biding (<textInput text="{myInstance.toString()}"/>) > , function binding works fine > except the itemRenderer (<textInput text="{data.toString()}"/>) > why? what is the problem? can't the VM detect the binding mechanism? (by > the way there isn't any compile time > warnings about the binding will not be able to run properly) > > 2nd: if i do not write toString (<textInput text="{myINstance}"/>), > although it calls toString method to find the > text value, function binding does never work (neither in itemRenderers nor > normal usage). > why? why cant the compiler detect the binding? > > thnks in advance. > > > Frederico Garcia wrote On 12/26/2007 05:38 PM: > > Jhonny Everson escreveu: > > > > I guess that your solution has a problem, the circular reference to > > toString. > > > > it could be something like: > > > > [Bindable] public var stringValue:String = ""; > > public function toString():String { > > > > ... ( some processing that results in a string var 'string1') > > > > stringValue= string1; > > return stringValue; > > } > > > > > > On 12/26/07, * Frederico Garcia* <[EMAIL > > PROTECTED]<fmotagarcia%40kemelyon.com> > > <mailto:[EMAIL PROTECTED] <fmotagarcia%40kemelyon.com>>> wrote: > > > > yigit escreveu: > > > hi all; > > > i have a custom class which has a toString method; so i can > > directly use > > > it as a source to textInput's text field. > > > i want to make binding work, i mean when the result of the toString > > > changes, i want the view to update itself automatically. > > > nameID field of roleRef is an instance of my class that implements > > > toString with function biding. > > > when i use this way: > > > <mx:Label id="lbl" text="{roleRef.nameID}"/> > > > function binding on toString does not work > > > when i use this way: > > > <mx:Label id="lbl" text="{roleRef.nameID.toString()}"/> > > > function biding on toString works, but inside an item renderer, > > it does > > > not work. > > > <mx:Label id="lbl" text="{data.nameID.toString()}"/> > > > > > > > > > is this a compiler bug or is this the normal behavior? > > > > > > > > > -- > > > Flexcoders Mailing List > > > FAQ: > > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> > > > Search Archives: > > http://www.mail-archive.com/flexcoders%40yahoogroups.com > > > Yahoo! Groups Links > > > > > > > > > > > > > > > __________ NOD32 2747 (20071225) Information __________ > > > > > > This message was checked by NOD32 antivirus system. > > > http://www.eset.com > > > > > > > > > > > > > > I believe you can only bind vars and setters. By binding a function i > > think it will only execute the function once. An easy workaround > > is to > > have a var containg the result of the toString function and bind the > > property to that var. Something like: > > > > [Bindable] public var stringValue:String = ""; > > public function toString():String { > > stringValue= this.toString(); > > return stringValue; > > } > > > > <mx:Label id="lbl" text="{data.nameID.stringValue}"/> > > > > Regards > > > > Frederico Garcia > > > > > > > > > > -- > > Jhonny Everson > > > > __________ NOD32 2747 (20071225) Information __________ > > > > This message was checked by NOD32 antivirus system. > > http://www.eset.com > Yes, indeed there was a circular reference to toString. Thanks for the > correction. The general concept is the same though, and I think it's the > best way to solve the "bind to function" problem. > > Regards > > Frederico Garcia > > > > -- j:pn \\no comment

