5 Replies Latest reply on Jun 2, 2010 1:58 PM by Yogi_K

    Problem with automated height/width after applying effect

    Yogi_K

      Hey guys,

      I have a panel that automatically resizes after some other contents is being added. All the time there is a scale-effect. Whenever I move the mouse over any of those children they zoom in and there the height & width of the parent container automatically resizes.

       

      However I have a minimize button for that one along with a resize effect. I can resize the complete container to a minimize size (e.g. 40x40), but when I resize back with the same effect, the panel does not automatically resizes with added children anymore.

       

      I did not set any special properties on the panel from the beginning, but some property must be different now. It is not "autoLayout" and also the "percentageWidth/Height" does not work properly as that command will cause the panel to stretch over the complete stage. Any suggestions here?

        • 1. Re: Problem with automated height/width after applying effect
          TeotiGraphix Level 3

          Hi,

           

          Usually what happens with effects is they set the explicit width and height of a component. This means that before you minimize the container, these values are not set. When you minimize the container, the explicitWidth and explicitHeight are set. Normally a layout or container will size the component with setActualSize() or setLayoutBoundsSize(). This does not lock the component into an explicit state.

           

          Sometiems after an effect I call;

           

          myComponent.width = NaN;
          myComponent.height = NaN;
          

           

          This will reset the explicit values to NaN and force the component's layout to re-measure and layout out based on it's preferred sizes. In your case, before the minimize effect occured

           

          Mike

          • 2. Re: Problem with automated height/width after applying effect
            Yogi_K Level 1

            Mmmh...that does not seem to solve the issue for me. Even when setting the width and height to NaN before the effect is played, it will still lead to a fixed height and width of the parent panel container. When I add new children the parent container is not properly resized, means that the chiildren just go beyond the parent container's border.

             

            Setting these parameters after the effect is done leads to the following crash:

            ArgumentError: Error #2004: One of the parameters is invalid.

            at flash.display::Graphics/drawRect()

            at spark.accessibility::PanelAccImpl/eventHandler()[E:\dev\4.0.0\frameworks\projects\spark\s rc\spark\accessibility\PanelAccImpl.as:361]

            at flash.events::EventDispatcher/dispatchEventFunction()

            at flash.events::EventDispatcher/dispatchEvent()

            at mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:12266]

            at mx.core::UIComponent/dispatchResizeEvent()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9641]

            at mx.core::UIComponent/commitProperties()[E:\dev\4.0.0\frameworks\projects\framework\src\mx \core\UIComponent.as:7866]

            at spark.components.supportClasses::SkinnableComponent/commitProperties()[E:\dev\4.0.0\frame works\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:414]

            at mx.core::UIComponent/validateProperties()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:7772]

            at mx.managers::LayoutManager/validateProperties()[E:\dev\4.0.0\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:572]

            at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:730]

            at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]

            at flash.utils::Timer/_timerDispatch()

            at flash.utils::Timer/tick()

             

            Here is my code...anything wrong here.

             

            private function recreateWindow(e:MouseEvent)//thrown once the user moves his mouse over the minimized panel

            {

                 myResizeEffect.heightFrom = 40;

                 myResizeEffect.heightFrom = 40;

                 myResizeEffect.heightFrom = lastHeight;

                 myResizeEffect.heightFrom = lastWidth;

                 myResizeEffect.play();

                 myResizeEffect.addEventListener(EffectEvent.EFFECT_END,resetMinimizeValues);

            }

             

            private function resetMinimizeValues(event:EffectEvent):void

            {

                 myResizeEffect.removeEventListener(EffectEvent.EFFECT_END,resetMinimizeValues);

                 //adding the old listeners before the panel was minimized

                 this.width = NaN;//crash

                 this.height = NaN;//crash

             

            }

             

            Any suggestions?

            ...and how can I remove the "Question answered"-tag...?

            • 3. Re: Problem with automated height/width after applying effect
              TeotiGraphix Level 3

              Hi,

               

              I could help with this but not knowing exactly how you are doing things, it's a wasted guess.

               

              Can you create a small app that reproduces what you are doing?

               

              Those values sholdn't be called in the effectEnd handler since the component has not yet validated again.

               

              Mike

              • 4. Re: Problem with automated height/width after applying effect
                Yogi_K Level 1

                Hi Mike,

                thanks for your help. I left you a fxp in that rar-file:

                 

                http://www.yogi-klatt.de/privates/demo.rar

                 

                The error also appears there. As I said working with NaN just crashes the whole application, I am a bit lost here

                • 5. Re: Problem with automated height/width after applying effect
                  Yogi_K Level 1

                  I've tried playing around with it a bit more, but still no luck.

                   

                  Even if I call this.setLayoutBoundsSize(), the children are not influenced by that...any suggestions?