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] 
> <mailto:[EMAIL PROTECTED]>> 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

Reply via email to