6 Replies Latest reply on Oct 23, 2009 11:09 AM by Chet Haase

    Move3D, is there a way to restore a target?

    KenichiM Level 1

      I want to restore a target after running it through a Move3D effect to its original position, so that I can run the same animation again.  For example if I run the following:

       

              <s:Sequence id="fadeOutItem">
                  <s:Parallel >
                      <s:Move3D zBy="5000" xBy="1000" yBy="1000" duration="1000" />
                      <s:Fade alphaTo="0" duration="500" />               
                  </s:Parallel>
                  <s:SetAction property="visible" value="false" />
                  <s:Move3D zBy="-5000" xBy="-1000" yTo="-1000" duration="0" />           
              </s:Sequence>

       

      I attempt to restore by running a Move3D again with a duration of zero, but it doesn't seem to restore the position.  I also tried creating a new instance of the target object each time, but that its starting postion seems to change.  I also tried setting: target.postLayoutTransformOffset = new TransformOffset(). But that didn't seem to work.  It appears like the parent container has also been transformed somehow.  What am I missing?

        • 1. Re: Move3D, is there a way to restore a target?
          David_F57 Level 5

          you have a few choices

           

          play("myTarget",true) which basically runs the transition in reverse when finished,

           

          or you can set an effectend handler and simply reset the objects values by extracting the moveby values from it.

           

          I haven't actually played with the transitions that much but the target properties are not updated until after the transition completes maybe oneffectupdate maybe a place to prevent target properties updating then refeshing the display(not to sure about this idea).

           

          David

          • 2. Re: Move3D, is there a way to restore a target?
            Chet Haase Level 3

            Not sure if this is the extent of your problem, but note that you have 'yBy' in the first effect and 'yTo' in the 0-duration effect. These aren't opposites (unless your starting position was actually y=-1000)

             

            Chet.

            • 3. Re: Move3D, is there a way to restore a target?
              KenichiM Level 1

              Sorry that was just a typo.

              • 4. Re: Move3D, is there a way to restore a target?
                Chet Haase Level 3

                Okay, then another problem in the code is that you're not restoring the alpha value. Fade will animate alpha to 0 (as specified) ... and will leave it there. If you don't restore alpha to 1 somewhere (such as by adding another SetAction after the one you have to set alpha to 1) then it will stay transparent.

                 

                Not sure if this is part of your problem, but I fixed a bug with zero-duration animations a couple of weeks ago (post Beta2), so you might grab the latest build if you still can't get it to work with the alpha fix above. I made your code work for me with the 2 adjustments I suggested.

                 

                Chet.

                1 person found this helpful
                • 5. Re: Move3D, is there a way to restore a target?
                  KenichiM Level 1

                  Thanks.  I found the problem...not sure why it works now - maybe I just inadvertently fixed a typo but here is what I had

                   

                          <s:Sequence id="fadeOutItem" effectEnd="doNext()">
                              <s:SetAction property="visible" value="true" />
                              <s:SetAction property="alpha" value="1" />
                              <s:Parallel duration="500">
                                  <s:Move3D id="fadeOutMove" zBy="5000"  />
                                  <s:Fade alphaTo="0" />
                              </s:Parallel>
                              <s:SetAction property="visible" value="false" />
                              <s:Move3D id="fadeOutRestore" zBy="-5000" duration="0" />           
                          </s:Sequence>

                   

                  And the actionscript to invoke it as:

                   

                                          this.fadeOutMove.xBy = Math.random()*3500;
                                          this.fadeOutMove.yBy = Math.random()*1200;           
                                          this.fadeOutRestore.xBy = -this.fadeOutMove.xBy;
                                           this.fadeOutRestore.yBy =  -this.fadeOutMove.yBy;             

                   

                                            this.fadeOutItem.play([this.prep1]);

                   

                  I changed it to store the move values in a local variable and everything seems to work:

                   

                                          var xBy:Number = Math.random()*3500;
                                          var yBy:Number = Math.random()*1200;           
                                         
                                          this.fadeOutMove.xBy = xBy;
                                          this.fadeOutMove.yBy = yBy;
                                          this.fadeOutRestore.xBy = -xBy;
                                          this.fadeOutRestore.yBy = -yBy;


                                       this.fadeOutItem.play([this.prep1]);

                  • 6. Re: Move3D, is there a way to restore a target?
                    Chet Haase Level 3

                    Well, for one thing you're Sequence code below has an additional SetAction call at the beginning that sets an opaque alpha value before it plays - this is similar to the fix I suggested (except it makes it visible right before starting instead of after it finishes).

                     

                    Anyway, good you got it working.

                     

                    Chet.