1 Reply Latest reply on Dec 15, 2009 5:59 AM by deshggg

    Line tween in AS2 (using CS3)

    deshggg Level 1

      Hey everyone,

       

      I currently have a little animation when my site opens which starts from a point in the middle of the screen and this exands horizontally into a line. This line makes up the final top and bottom of the viewing window so once it reaches it's full width it splits and moves to the top or bottom of the window (with expanding vertical lines at either side). Once finished it ends up as a rectangular box within which my content sits. I have created this using lines and motion tweens within CS3, but i am trying to redo it using purely AS2 (so i can dynamically change the colour of the lines etc). I am having some wierd problems, although i have never used the tween class in actionscript, so i'm sure i'm doing something stupid.

       

      The way i have done it is to create a movieclip, draw a line within it then tween the height of the movie clip (for a vertical expanding line). This sort of works but for some reason the width also seems to increase no matter what i do, what's particularly strange is the amount the width changes is directly relative to the original height of the line. The code i have is:

       

      import mx.transitions.Tween;

      import mx.transitions.easing.*;

       

      this.createEmptyMovieClip("kText", 10);

      kText._x=10;

      kText._y=10;

      kText.lineStyle(2, 0xFF0000, 100);

      kText.moveTo(0, 0);

      kText.lineTo(0, 50);

      kText._height=50;

      kText._width=2;

       

      var xScaleT:Tween = new Tween(kText, "_height", None.easeNone, 50, 400, 3, true);

      trace (kText._height);

       

      xScaleT.onMotionFinished = function() {
          trace (kText._height);
          trace (kText._width);
          trace (kText._y);
          trace (kText._x);

      };

       

      Obviously there are a number of trace's for testing and i have also added explicit definitions of the movieclips height and width to confirm this wasnt' the problem (although this has had no effect). As i say i'm sure i'm doing something stupid, it doesn't seem quite right to be tweening the height of the movieclip, but i'm not sure how to tween the moveto, or if that's even possible?

       

      I would really appreciate any pointers anyone has got one this, i can get it to tween other more standard variables (changing _x/_y etc), but am really having problems with this.

       

      Thanks so much for your help as ever everyone,

       

      Dave

        • 1. Re: Line tween in AS2 (using CS3)
          deshggg Level 1

          I think i was being stupid and i have redone this using setinterval and am drawing small sections of each line at prespecified intervals. This works absolutely fine, but it isn't anywhere near as smooth as my current tween, no matter what values i set the length increase or interval at. I wondered if anyone had any pointers as to the best values to use so as to simulate smooth increase in length, or if there is something else i can do to alleviate the problem?

           

          Thanks so much guys,

           

          Dave