0 Replies Latest reply on Feb 7, 2014 2:37 AM by Dieter411

    Solution: paint a doted line (simple function - 4free ^^)

    Dieter411

      hi folks,

       

      now here is a simple function to paint a doted line - copy the code below and call it (you have to change the "this.*" elements for your own use)

       

      sample call:   dotIt(1000, 100, 100, "horizontal");

       

      // paint a doted line
      private function dotIt(length:int, startX:int, startY:int, direction:String):void
      {
        var currentLength:int;  // dot length counter
        var dotLength:int = 5;  // dot length
        var paintDot:Boolean = true;

       

        length -= dotLength;  // subtract one dot length for no over painting
        this.container.graphics.lineStyle(0.5,this.fontColor,0.5);
        this.container.graphics.moveTo(startX,startY);
       
        for(currentLength=0; currentLength <= length; currentLength+=dotLength)
        {
         // paint dot
         if(paintDot==true)
         {
          this.container.graphics.lineStyle(0.5,this.fontColor,0.5);
          switch(direction)
          {
           case "horizontal":
            this.container.graphics.lineTo(startX+=dotLength,startY);
            break;
           case "vertical":
            this.container.graphics.lineTo(startX,startY+=dotLength);
            break;       
          }
          paintDot=false;
         }
          // paint space
         else
         {
          this.container.graphics.lineStyle(0,this.fontColor,0);
          switch(direction)
          {
           case "horizontal":
            this.container.graphics.lineTo(startX+=dotLength,startY);
            break;
           case "vertical":
            this.container.graphics.lineTo(startX,startY+=dotLength);
            break;       
          }
          paintDot=true;
         }
        }
      }

       

      thx4replies ^^