Give this a try:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
    <![CDATA[
        import mx.binding.utils.BindingUtils;

        [Bindable]
        public var foo:String = "hi";

        public function init():void
        {
            BindingUtils.bindSetter( handleChange, this, "foo" );
        }
       
        public function handleChange( str:String ):void
        {
            trace( "handleChange( " + str + " )" );
        }
    ]]>
</mx:Script>
<mx:Button label="go" click="foo='value of foo changed'"/>
</mx:Application>









On 9/20/06, thunderstumpgesatwork <[EMAIL PROTECTED]> wrote:

Hi.. I was asking about how to do it through ActionScript...

I have done it and know it works in mxml. I'm talking about adding a
property binding using just actionscript, and some incantation of a

mx.binding.utils.ChangeWatcher or mx.binding.utils.BindingUtils

Thunder



--- In [email protected], "gsamsa" <[EMAIL PROTECTED]> wrote:
>
>
> This should work pretty much just the way your example works, so maybe
> one of your parameters isn't bindable?
>
> The following example works, and also illustrates another less elegant
> way of accomplishing the same thing
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute">
> <mx:Button label="{formatLabel(prodName1.text,prodPart1.text)}"
> x="10" y="40"/>
> <mx:TextInput id="prodName1" y="10" x="10"/>
> <mx:TextInput id="prodPart1" x="193" y="10"/>
>
> <mx:Button label="{formatLabel2}" x="10" y="128"/>
> <mx:TextInput id="prodName2" change="dispatchEvent(new
> Event('labelChanged'))" x="10" y="98"/>
> <mx:TextInput id="prodPart2" change="dispatchEvent(new
> Event('labelChanged'))" x="193" y="98"/>
>
> <mx:Script>
> <![CDATA[
> private function formatLabel(x:String, y:String) : String
> {
> return (x + ":" + y);
> }
>
> [Bindable("labelChanged")]
> private function get formatLabel2() : String
> {
> return (prodName2.text + ":" + prodPart2.text);
> }
> ]]>
> </mx:Script>
>
> </mx:Application>
>
> --- In [email protected], "thunderstumpgesatwork"
> <thunder.stumpges@> wrote:
> >
> >
> > Hi guys,
> >
> > I know in mxml you can do data binding like this:
> >
> > <mx:Button label="{formatLabel(someBindableTextField)}" />
> >
> > where any time the bindable property "someBindableTextField" changes,
> > the binding fires, and the label is replaced with the result of the
> > function.
> >
> > This is even more powerful if the function parameters has two bindable
> > properties. When either one changes, the function executes, and the
> > label is updated.
> >
> > How can this be achieved in ActionScript?
> >
> > I have used the ChangeWatcher, and the BindingUtils classes but don't
> > see a simple solution.
> >
> > thanks for any ideas =)
> > Thunder
> >
>


__._,_.___

--
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
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to