5 Replies Latest reply on Mar 31, 2009 2:54 PM by jose3

    Parallel effect reversing on its own. FLEX BUG.

    jose3
      Hi,
      The problem is that the parallel effect (that includes resize and move) plays well with my custom component, however when it reaches the EFFECT_END, it plays in reverse to its original position, on its own. I cannot figure it out why. This reverse effect is done in half of the duration set.

      This is the code:

      private function setLayoutAndPosition( pod:*, rect:Rectangle ):void
      {

      // Transition the location
      var move:Move = new Move( pod );
      move.xFrom = pod.x;
      move.xTo = rect.x;
      move.yFrom = pod.y;
      move.yTo = rect.y;
      move.duration = 2000;

      // Transition the size
      var resize:Resize = new Resize( pod );
      resize.widthFrom = pod.width;
      resize.widthTo = rect.width;
      resize.heightFrom = pod.height;
      resize.heightTo = rect.height;
      resize.duration = 2000;

      var parallel:Parallel = new Parallel();
      parallel.addChild(move);
      parallel.addChild(resize);
      parallel.play();

      }


      I am utilizing an effect taken from the source code of the Flex Developer Center called Community Widgets ( bottom of the page) which is working correctly. Its pretty cool eh!.


      BTW: Took me some time to find out why I couldn't run the source code. You have to rename ListEvent to any other name.

      If anybody has any idea please le me know,

      Many thanks!

      Jose.




        • 1. Re: Parallel effect reversing on its own.
          injpix Level 3
          Are you sure there is no other code in the application that would cause this to happen? Such as a reverse() call somewhere. Also, how do you know when EFFECT_END has been fired off?
          • 2. Parallel effect reversing on its own.
            jose3 Level 1
            Hi myIP,
            After days of trying different things I figured out what was the problem, I am not sure if it is a BUG in Flex or if it is a natural behabiour.

            The thing is that if you position a component (Canvas FE) with constraintColumns and constraintRows and then you apply an effect that affects its position or size, after the effect reaches the wished size-position the components goes back to the original size-position on its own. Once back the EFFECT_END is dispached.

            Here is an example:



            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
            layout="absolute"
            applicationComplete="init()">

            <mx:Script>
            <![CDATA[

            import flash.geom.Rectangle;
            import flash.utils.Dictionary;

            import mx.core.Application;
            import mx.effects.Move;
            import mx.effects.Parallel;
            import mx.effects.Resize;
            import mx.events.EffectEvent;

            private var minimizedLayout:Dictionary = new Dictionary();;

            private function init():void {
            minimizedLayout[ can ] = new Rectangle( 5, 200, 300, 50 );
            can.addEventListener(EffectEvent.EFFECT_END, onEffectEnd);
            }

            private function onClick(e:Event):void {
            effectEndText.text = "";
            setLayoutAndPosition( can, minimizedLayout[can] );
            }

            private function setLayoutAndPosition( pod:*, rect:Rectangle ):void
            {

            // Transition the location
            var move:Move = new Move( pod );
            move.xFrom = pod.x;
            move.xTo = rect.x;
            move.yFrom = pod.y;
            move.yTo = rect.y;
            move.duration = 1000;

            // Transition the size
            var resize:Resize = new Resize( pod );
            resize.widthFrom = pod.width;
            resize.widthTo = rect.width;
            resize.heightFrom = pod.height;
            resize.heightTo = rect.height;
            resize.duration = 1000;

            var parallel:Parallel = new Parallel();
            parallel.addChild(move);
            parallel.addChild(resize);
            parallel.play();

            }

            private function onEffectEnd(e:EffectEvent):void {
            effectEndText.text = "Effect "+e.effectInstance.className+" ended";
            }

            ]]>
            </mx:Script>

            <mx:constraintColumns>
            <mx:ConstraintColumn id="col1" width="5%"/>
            <mx:ConstraintColumn id="col2" width="20%"/>
            </mx:constraintColumns>

            <mx:constraintRows>
            <mx:ConstraintRow id="row1" height="5%"/>
            <mx:ConstraintRow id="row2" height="20%"/>
            </mx:constraintRows>


            <mx:Button label="Move Canvas" x="333" click="onClick(event)" y="29" height="72"/>

            <mx:Canvas id="can" backgroundColor="#D91414"
            left="col1:10" right="col2:0"
            top="row1:10" bottom="row2:0" />

            <mx:TextArea id="effectEndText" x="333" y="132" width="100" height="73"/>

            </mx:Application>





            If this is a normal behabiour and there is nothing to do with it, I can just try to end the effect somewhere in the middle, else I listen to any suggestion. Any help is appreciated.


            Many thanks myIP,

            Jose


            • 3. Re: Parallel effect reversing on its own.
              Level 7

              "jose3" <webforumsuser@macromedia.com> wrote in message
              news:gqpias$2r8$1@forums.macromedia.com...
              > Hi myIP,
              > After days of trying different things I figured out what was the problem,
              > I am
              > not sure if it is a bug or if it is a natural behabiour of Flex.
              >
              >
              > The thing is that if you position a component (Canvas FE) with
              > constraintColumns and constraintRows and then you apply an effect that
              > affects
              > its position or size, after the effect reaches the EFFECT_END the
              > components
              > goes back to the original position-size on its own.
              >
              > Here is an example:
              >
              > <?xml version="1.0" encoding="utf-8"?>
              > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
              > layout="absolute"
              > applicationComplete="init()">
              >
              > <mx:Script>
              > <![CDATA[
              >
              > import flash.geom.Rectangle;
              > import flash.utils.Dictionary;
              >
              > import mx.effects.Move;
              > import mx.effects.Parallel;
              > import mx.effects.Resize;
              > import mx.events.EffectEvent;
              >
              > private var minimizedLayout:Dictionary = new Dictionary();;
              >
              > private function init():void {
              > minimizedLayout[ can ] = new Rectangle( 5, 200, 300, 50 );
              > }
              >
              > private function onClick(e:Event):void {
              > setLayoutAndPosition( can, minimizedLayout[can] );
              > }
              >
              > private function setLayoutAndPosition( pod:*, rect:Rectangle ):void
              > {
              >
              > // Transition the location
              > var move:Move = new Move( pod );
              > move.xFrom = pod.x;
              > move.xTo = rect.x;
              > move.yFrom = pod.y;
              > move.yTo = rect.y;
              > move.duration = 1000;
              >
              > // Transition the size
              > var resize:Resize = new Resize( pod );
              > resize.widthFrom = pod.width;
              > resize.widthTo = rect.width;
              > resize.heightFrom = pod.height;
              > resize.heightTo = rect.height;
              > resize.duration = 1000;
              >
              > var parallel:Parallel = new Parallel();
              > parallel.addChild(move);
              > parallel.addChild(resize);
              > parallel.play();
              >
              > }
              >
              > ]]>
              > </mx:Script>
              >
              > <mx:constraintColumns>
              > <mx:ConstraintColumn id="col1" width="5%"/>
              > <mx:ConstraintColumn id="col2" width="20%"/>
              > </mx:constraintColumns>
              >
              > <mx:constraintRows>
              > <mx:ConstraintRow id="row1" height="5%"/>
              > <mx:ConstraintRow id="row2" height="20%"/>
              > </mx:constraintRows>
              >
              >
              > <mx:Button label="Move Canvas" x="333" click="onClick(event)" y="29"
              > height="107"/>
              >
              > <mx:Canvas id="can" backgroundColor="#D91414"
              > left="col1:10" right="col2:0"
              > top="row1:10" bottom="row2:0" />
              >
              > </mx:Application>
              >
              >
              > If this is a normal behabiour (if anybody knows about it) I can just try
              > to
              > end the effect after EFFECT_END, else I listen to any suggestion.
              >
              > How should I proceed it it is a bug?

              Listen for the effect end, and then explicitly set the width and height of
              the affected component to the new size.


              • 4. Parallel effect reversing on its own. FLEX BUG.
                jose3 Level 1
                Hi,
                It didn't work out, thanks for the tip anyway. I even tried setting the new coordinates in constraints values byt the same.

                It's very annoying to see this behavior on Flex, I am sure this is a bug. I am so frustrated that I want to use Caurina Tweener…..I have spent plenty of time on this and still in the same place.

                Jose.
                • 5. Re: Parallel effect reversing on its own. FLEX BUG.
                  jose3 Level 1
                  There is a very similar bug already reported, I posted my code too.

                  http://bugs.adobe.com/jira/browse/SDK-19737

                  Thanks for all the answers anyway,

                  Jose