Hello Hissam.
Thanks for an answer. Your answer deep b
The VBox component does not change height property after change in the
my component. I don't know to this moment how to upgrade width or
height properties after change in container. For this reason I use
next way for  finish my work:

1. In asd.mxml to set _watcher to watch for the height property in asd
componet.
2. After the state is change, dispatch the event and set the
_oldValueHeight
3. Catch the event in main application and do handleChangeState
function;

Thanks.
Code:

Test.mxml

<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" verticalScrollPolicy="on" xmlns:local="*">

<mx:Script>
        <![CDATA[
                import mx.core.UIComponent;
        import flash.events.Event;

                private function handleChangeState(event:Event):void
                {
                        trace(event.currentTarget.oldValueHeight);
                        trace(event.currentTarget.height);
                        container.height = my.height -= 
event.currentTarget.oldValueHeight;
                        container.height = my.height += 
event.currentTarget.height;
                }

        ]]>
</mx:Script>

<mx:ViewStack id="my" borderThickness="1" borderStyle="solid">
        <mx:VBox id="container">
                <mx:VBox borderThickness="1" borderStyle="solid">
                        <local:asd id="myId" 
changeStateA='handleChangeState(event)'/>
                </mx:VBox>
                <mx:VBox borderThickness="1" borderStyle="solid">
                        <local:asd id="myIda" 
changeStateA='handleChangeState(event)'/>
                </mx:VBox>
        </mx:VBox>
</mx:ViewStack>
<mx:Button x="700" label="Update" click="{my.height = '100%' as
Number}"/>
</mx:Application>

===========================
asd.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; width="588"
creationComplete="initComp()">
        <mx:states>
                <mx:State name="asd">
                <mx:RemoveChild target="{myId}"/>
                </mx:State>
        </mx:states>

        <mx:Metadata>
                [Event(name='changeStateA', name='flash.events.Event')]
        </mx:Metadata>

        <mx:Script>
                <![CDATA[
                        import mx.binding.utils.BindingUtils;
                        import mx.binding.utils.ChangeWatcher;
                        import flash.events.Event;

                        private var _watcher:ChangeWatcher;
                        private var _oldValueHeight:int;
                        private var _firstRun:Boolean = true;

                        private function initComp():void
                        {
                                _watcher = BindingUtils.bindSetter(myFun, this, 
'height');
                                _oldValueHeight = this.height;
                        }
                        public function get oldValueHeight():int
                        {
                                return _oldValueHeight;
                        }
                        private function myFun(event):void
                        {
                                if(_firstRun)
                                {
                                        _firstRun = false;
                                        return;
                                }
                                var e:Event = new Event('changeStateA');
                                dispatchEvent(e);
                                _oldValueHeight = this.height;
                        }

                        private function onClick(event:Event):void
                        {
                                if(currentState==null || currentState=='')
                                        currentState='asd';
                                else
                                        currentState='';
                        }
                ]]>
        </mx:Script>
        <mx:Button x="600" label="asd" click="onClick(event)"/>
        <mx:Text text="asdsad" width="100"/>
        <mx:Canvas id="myId">
                <mx:Text id="myTx" text="ad asd a sdf sdf sdfsdf sdf sdf d aad 
asd a
sdf sdf sdfsdf sdf sdf d aad asd a sdf sdf sdfsdf sdf sdf d as"
width="100"/>
        </mx:Canvas>
</mx:VBox>

--~--~---------~--~----~------------~-------~--~----~
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