3 Replies Latest reply on Oct 8, 2009 7:32 AM by kglad

    Movieclip control

    Rootle Level 1

      I've almost got a bit of flash finished, I am hoping someone can help me make a bit of code to finish it off. The .swf so-far is here: http://www.samhumphrey.co.uk/new/clock2.html

       

      ..for some reason the file won't attach but the important bit of code I have so-far is below.

       

      I need to make a line to litterally 'connect the dots', each of which is one end of a movieclip, I know it needs to boil down to ' line x,y, to (movieclipname)x,y, but cannot work it out!

       

      Thanks, R.

       

      time.onChanged = function()

      {

      if(time.text.length == 4) {

      var hours:Number = parseInt(time.text.substr(0,2),10);

      hours *= 60;

      var minutes:Number = parseInt(time.text.substr(2,2),10);

      minutes += hours;

      while(minutes > 720) {

      minutes -= 720;

      }

      var lineNum:Number = Math.ceil(minutes/12);

      /*trace(lineNum);*/

      _root["line"+lineNum]._xscale += 20;

      _root["line"+lineNum]._yscale += 20;

        • 1. Re: Movieclip control
          kglad Adobe Community Professional & MVP

          if you're trying to draw a line from x1,y1 to x2,y2 using actionscript, use:

           

          this.createEmptyMovieClip("lineMC",this.getNextHighestDepth());  // <-unless you're using v2 components

           

          with(lineMC){

          lineStyel(1,0xff0000);

          moveTo(x1,y1);

          lineTo(x2,y2);

          }

          1 person found this helpful
          • 2. Re: Movieclip control
            Rootle Level 1

            I'm not sure what vs components are, but I tried something similar to this, but it didnt work because the spots move out in all directions, so I can't just add a value to the x and y value.

             

            Ids there some way i can combine this with a bit of code that finds the x and y value of the end of each spot movieclip? - as I could then use your suggestion as:

             

            (lineMC){

            lineStyel(1,0xff0000);

            moveTo(foundvalue x1,foundvaluey1);

            lineTo(new foundvalue x2, new y2);

            }

            • 3. Re: Movieclip control
              kglad Adobe Community Professional & MVP

              if you're trying to draw a line from dot1MC to dot2MC, use:

               

              with(lineMC){

              lineStyel(1,0xff0000);

              moveTo(dot1MC._x,dot1MC._y);

              lineTo(dot2MC._X, dot2MC._x);

              }

               

              and if you want to do that repeatedly because dot1MC and/or dot2MC are moving, repeatedly call lineF(lineMC):

               

              function lineF(mc:MovieClip){

              with(lineMC){

              clear();

              lineStyel(1,0xff0000);

              moveTo(dot1MC._x,dot1MC._y);

              lineTo(dot2MC._X, dot2MC._x);

              }

              }