• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

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

New Here ,
Jan 22, 2014 Jan 22, 2014

Copy link to clipboard

Copied

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 ^^

Views

444

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines