2 Replies Latest reply on Aug 18, 2009 12:13 PM by k.bitgood

    draw dynamically

    Beta2k

      hello!

       

      in my flash movie i have a rectangle which represents a seek bar of an audio player. on this rectangle i want to draw "points" or smaller "rectangles" at a specific place. these "points", should be placed at specific timemarks, which i have in a variable. these "points" should also be able to have a mouse-over-effect.

       

      this is the first time i want to draw something dynamically in flash, therefore i have no idea what would be the best practice to do so.

       

      it would be really appreciated if someone can point me to the right direction.

        • 1. Re: draw dynamically
          Beta2k Level 1

          okay let's try it another way:

           

          let's say i have a movieClip called "drawArea" on my stage. how can i draw a line WITHIN this movie clip? so that the reference point for moveTo and lineTo methods are the movie clip's coordinates..

           

          thanks very much.

           

          edit:

           

          i tried it with the following code but the rectangle i want to draw gets overlapped by the original-movieclip which already exists. the orinigal mc has a depth of -16383 and my dynamically drawed mc has a depth of 1

           

          rectangle_mc._x = 100;
          rectangle_mc._y = 100;
          drawRoundedRectangle(mymc, 240, 18, 20, 0x99FF00, 100);
          
          function drawRoundedRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void {
              with (target_mc) {
               mymc.createEmptyMovieClip ("test", 1)
                  beginFill(fillColor, fillAlpha);
                  moveTo(cornerRadius, 0);
                  lineTo(boxWidth - cornerRadius, 0);
                  curveTo(boxWidth, 0, boxWidth, cornerRadius);
                  lineTo(boxWidth, cornerRadius);
                  lineTo(boxWidth, boxHeight - cornerRadius);
                  curveTo(boxWidth, boxHeight, boxWidth - cornerRadius, boxHeight);
                  lineTo(boxWidth - cornerRadius, boxHeight);
                  lineTo(cornerRadius, boxHeight);
                  curveTo(0, boxHeight, 0, boxHeight - cornerRadius);
                  lineTo(0, boxHeight - cornerRadius);
                  lineTo(0, cornerRadius);
                  curveTo(0, 0, cornerRadius, 0);
                  lineTo(cornerRadius, 0);
                  endFill();
              }
          }
          
          trace (mymc.getDepth());
          trace (mymc.test.getDepth());
          
          • 2. Re: draw dynamically
            k.bitgood Level 1

            Ok, for your first question you can use lineTo and moveTo inside a movie clip by using this:

             

            my_mc.moveTo(0,0);
            my_mc.lineTo(0,0);
            

             

            This of course draws nothing, but the (0,0) is inside the movie clip and therefore equal to (my_mc._x, my_mc._y). But you have to remember that now all your other movements, lines, and curves are all relative to this point.

             

            For you second question i don't fully understand what you mean by "gets overlapped by the original-movieclip", but I you might try replacing your 7th line with this:

             

            mymc.createEmptyMovieClip ("test", mymc.getNextHighestDepth())

             

            This will put your "test" movieclip on the top of everything inside your mymc movieclip. If this doesn't work, you could try replacing "mymc" with "_root", but that might not be what you want.

             

            Hope this is helpful