Title: Message
That did it, thanks a lot.

Greg Andora
-----Original Message-----
From: Ashish Goyal [mailto:[EMAIL PROTECTED]
Sent: Friday, April 01, 2005 11:35 AM
To: '[email protected]'
Subject: RE: [flexcoders] [ChangeEvent()] and binding

Hi Greg,
The problem is you are not dispatching the "myVar_changed" event. Add this line in your setter function and it should work.
 
dispatchEvent({type: "myVar_changed"});
Alternately, you can remove the whole ChangeEvent code and let Flex compiler do the work for you. Your MXML component code will look like:
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.macromedia.com/2003/mxml">
        <mx:Script>
        <![CDATA[
 
                var myVar : String;
              
        ]]>
        </mx:Script>
        <mx:TextInput id="thisText" change="myVar=thisText.text;" />
</mx:Canvas>
 
Thanks
-Ashish
 
 
 


From: Andora, Greg [mailto:[EMAIL PROTECTED]
Sent: Friday, April 01, 2005 11:05 AM
To: '[email protected]'
Subject: [flexcoders] [ChangeEvent()] and binding

Hi all,

I'm trying to expose a property of a custom component to be available for binding and can't seem to get it tor work.  Below is the code for a very basic example of what I'm trying to do.

I have a property (myVar) whose changes are triggered by something inside of the custom component.  The problem is, the changes to the property aren't being broadcast to the page using the component so that the bindings in the page are updated.

<!--Page running the component-->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns:cc="*">
        <mx:Script>
        <![CDATA[
                import mx.controls.Alert;
        ]]>
        </mx:Script>
        <!-- Instance of my component -->
        <cc:test id="testInput" />
        <!--Button to Alert the value of my variable shows the variable is being updated correctly -->
        <mx:Button click="Alert.show(testInput.myVar)" />
        <!-- Label whose text attribute is bound to the variable....doesn't get updated -->
        <mx:Label text="{testInput.myVar}" />
</mx:Application>


<!-- Component - test.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.macromedia.com/2003/mxml">
        <mx:Script>
        <![CDATA[
                import mx.controls.Alert;
                private var _myVar : String;
               
                [ChangeEvent("myVar_changed")]
                public function get myVar() : String
                {
                        return _myVar;
                }
                public function set myVar(newVal : String) : Void
                {
                        _myVar = newVal;
                }
        ]]>
        </mx:Script>
        <mx:TextInput id="thisText" change="myVar=thisText.text;" />
</mx:Canvas>


Thank you,
Greg Andora


----
This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.

To reply to our email administrator directly, send an email to
[EMAIL PROTECTED]

Littler Mendelson, P.C.
http://www.littler.com




Yahoo! Groups Links

----
This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.

To reply to our email administrator directly, send an email to
[EMAIL PROTECTED]

Littler Mendelson, P.C.
http://www.littler.com


Reply via email to