Menu

multiStart / multiSetter

Help
valley
2005-11-25
2013-04-01
  • valley

    valley - 2005-11-25

    hi,
    i am trying to animate 4 JFrame objects (from ASWing library) at the same time with the Animator class.
    Doing so 4 times (with start and setter) is quite
    slow. now there's the possibility to use the way
    with multiStart and multiSetter.
    does anyone have an example how this works ?
    also in a more general way i would like to use
    the multistart/multisetter approach, i.e. if
    we have n JFrame objects to animate in the same
    way.

    thanks for your help.
    regards
    valley

     
    • Alex Uhlmann

      Alex Uhlmann - 2005-11-25

      Hi valley,

      please note that multiStart and multiSetter only make sense if your animations have the same end value. To get more information about them, check out the invokeAnimation class of some classes in AP that use them. i.e. Alpha, Move and Scale, ColorTransform for a more complex example. The most efficient version of the more complex examples are in AP 1.08 Beta 4. Check out the the private initMultiMC method of the DropShadow class.

      Many classes in AP offer this functionality under the hood. You can use them with just specifying an Array of movieclips instead of one single movieclip. What would you need Animator for exactly? Couldn't you use the other higher level classes?

      And if you have some more docs for it I could add i.e. in Animator, please let me know. Currently I don't get to it.

      Also, if you find any bugs, please let me know as early as possible. I will release the final 1.07 version very soon. Please use the latest BETA of 1.07 for now.

      Best,
      Alex

       
    • valley

      valley - 2005-11-25

      hi alex,

      ok, then multiStart/multiSetter isn't the right
      choice; the aim is just to let the mentioned 4 (or
      better n) JFrame objects open (i.e. it's a resize
      from 0,0 to x,y) at the same time in a quadrant
      view (so not the same endpoint) and when the user wants to exit the frames have to close from x,y size to 0,0 again.
      i don't think that scale class is the right choice because with that the content of these 4 frames
      will scale too, and i want to be independent with
      the content size when the frames do change their
      size.

      here's the code i use 4 times (too slow):

      public function startAnimation():Void {
             
        var myAnimator:Animator = new Animator();       
        myAnimator.caller = myAnimator;   
        myAnimator.start = [this.frame.getSize().width,  
           this.frame.getSize().height];
        myAnimator.end = [this.endWidth, his.endHeight];
        myAnimator.setter = [[this,"scale"]];
        myAnimator.run(1000, Circ.easeOut);
      };
         
      private function scale(w:Number,h:Number) {   
        this.frame.setSize(w,h);   
      }

      these two methods are in a separate class that
      will be instantiated 4 times, where i pass
      the frame to be enlarged and the endWidth, endHeight as parameters.

      now could you tell me what is the best/fastest
      way to use for this task ?

      thank you very much.
      regards
      valley

       
    • Alex Uhlmann

      Alex Uhlmann - 2005-11-25

      This should not be slow. Are you sure the slowness comes from AP and not the class you are using to animate? Flash 7 and lower are quite slow in rendering.

      In your case AP calls this method every interval:

          public function mu(v:Array):Void {       
              var r:Object = this.ref;
              var s:Array = r.setter;
              var p:Object;
              var t:String;
              var f:Function;
              p = s[0][0];
              t = s[0][1];
              f = p[t];
              f.apply(p,v);
              r.caller.currentValues = v;
              r.caller["dispatchEvent"]({type:"onUpdate", target: r.caller, value: v});
          }   

      If you could get your setter methods to only accept a single parameter AP uses a faster method each interval. You might even be able to write only one Animator instance for all 4 animations to further improve.

      In this case Animator would call this method each interval:

          public function mm(v:Array):Void {       
              var r:Object = this.ref;
              var s:Array = r.setter;
              var i:Number = this.len;
              while(--i>-1) {
                  s[i][0][s[i][1]](v[i]);
              }
              r.caller.currentValues = v;
              r.caller["dispatchEvent"]({type:"onUpdate", target: r.caller, value: v});
          }

      which is a bit faster.

      Notice, that you could also try to use frame based tweening, which is in general faster and more precise than time based tweening.

      Best,
      Alex

       
    • valley

      valley - 2005-11-28

      hi alex,

      ok, i tried the whole thing with instances of
      the class one level more abstract (JWindow), and with that it runs much more performant.

      thanks a lot for your good and fast support.
      regards
      valley

       

Log in to post a comment.