Use a setter for the buttonText property and then in that setter assign button_mc.label.

 

The binding is executing after the createChildren method has been called.

 

Matt


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Rob Rusher
Sent: Thursday, November 03, 2005 6:08 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: How do you pass bindings into a custom component?

 

Yeah, I tried that. No workie.

Regards,
Rob

--- In flexcoders@yahoogroups.com, "JesterXL" <[EMAIL PROTECTED]> wrote:
>
> You have to put a change tag above the property in question. 
Check in the documentation for ChangeEvent:
>
> [ChangeEvent("change")]
> public var flavorStr:String;
>
> ----- Original Message -----
> From: Rob Rusher
> To: flexcoders@yahoogroups.com
> Sent: Thursday, November 03, 2005 11:47 AM
> Subject: [flexcoders] How do you pass bindings into a custom
component?
>
>
> I have an AS class that extends UIComponent. I can easily pass a
value into the component if it is a string, but if the property is
bound to something it does not come through.
>

>
> I've tried setting events to detect the change with no luck. Most
likely an error on my part.
>

>
> Anyone have ideas on how to do this?
>

>
> Main.mxml
>
> ==============================================
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*">
>
> <mx:TextInput id="myText" text="Click Me"/>
>
> <MyComponent id="myPanel" buttonText="{ myText.text }"/>
>
> </mx:Application>
>

>

>
> MyComponent.as
>
> ==============================================
>
> // Import all necessary classes.
>
> import mx.core.*;
>
> import mx.controls.*;
>

>
> class MyComponent extends UIComponent
>
> {
>
>             // Declare events
>
>             [Event("click")]
>

>
>             // Declare input property.
>
>             public var buttonText:String;
>

>
>             // Declare two children member variables.
>
>             public var text_mc:TextArea;
>
>             public var button_mc:Button;
>

>
>             function createChildren():Void
>
>             {
>
>                         if ( button_mc == undefined )
>
>                                     createClassObject(
Button, "button_mc", 1, { } );
>
>                         if ( text_mc == undefined )
>
>                                     createClassObject(
TextArea, "text_mc", 0, { preferredWidth: 150, editable: false } );
>
>                         button_mc.addEventListener( "click",
this );
>

>
>                         // assign input property to button's label
>
>                         button_mc.label = buttonText;
>
>             }
>

>
>             function layoutChildren()
>
>             {
>
>                         button_mc.move( text_mc.width / 2 - 5,
50 );
>
>             }
>

>
>             // Handle events that are dispatched by the children.
>
>             function handleEvent( eventObj:Object ):Void
>
>             {
>
>                         if ( eventObj.type == "click" )
>
>                                     text_mc.text = "You clicked
the button";
>
>             }
>

>
> }
>

>
> Regards,
>

>
> Rob Rusher
>

>
> RIA Consultant
>
> Macromedia Certified Flex Instructor
>
> e:[EMAIL PROTECTED] c:303.885.7044 im:robrusher
>

>
>
>
> --
> Flexcoders Mailing List
> FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com
>
>
>
> -------------------------------------------------------------------
-------------
> YAHOO! GROUPS LINKS
>
>   a..  Visit your group "flexcoders" on the web.
>    
>   b..  To unsubscribe from this group, send an email to:
>    [EMAIL PROTECTED]
>    
>   c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
>
>
> -------------------------------------------------------------------
-------------
>







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


YAHOO! GROUPS LINKS




Reply via email to