Hello

Try out this may help you.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
                horizontalAlign="center" verticalAlign="middle"
creationComplete="onCreationComplete(event)" >

        <mx:Script>
                <![CDATA[
                        import mx.controls.Button;
                        import mx.events.FlexEvent;
                        import mx.controls.TextInput;

                        private var minmumWidth : Number = 40;
                        private var txtButton : Button;

                        private function 
onCreationComplete(event:FlexEvent):void
                        {
                                txtButton = new Button();
                                txtButton.label = "hi" // default label
                                this.addChild(txtButton);
                        }
                        private function onTextChange(event:Event):void
                        {
                                txtButton.label = ( event.currentTarget as 
TextInput ).text;
                                txtButton.width = minmumWidth + ( 
event.currentTarget as
TextInput ).textWidth;
                        }
                ]]>
        </mx:Script>

        <mx:HBox >
                <mx:TextInput change="onTextChange(event)" />
        </mx:HBox>
</mx:Application>

Thanks
Virat Patel

On Apr 21, 7:45 pm, flex <[email protected]> wrote:
> hi all
> I am setting value of textinput to button' label at run time,   here i
> want that button should increase its width according to label.
> but not increasing width of button when i'm typing more text.
>
>  private var btn1:Button = new Button();
>  private function init():void{
>  hb.addChild(btn1);
>
> }
>
>  <mx:HBox id='hb' >
>         <mx:TextInput id="txt" change="btn1.label=txt.text" />
>  </mx:HBox>
>
> thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to