--- In flexcoders@yahoogroups.com, "havardfl" <[EMAIL PROTECTED]> wrote:
>
> In a project I'm working on I would like to represent data flowing
> through the system with dashed/dotted lines moving between two or more
> points.
> 
> I've done one implementation using the lineGradientStyle function to
> create dashes. This works, but I'm not pleased with the CPU load while
> the script is running. I'd like to draw 100+ lines, and my method of
> doing it isn't cutting it.
> 
> Does anyone know a great way of drawing animated dashed/dotted lines
> without using much CPU time?
>

This is my implementation btw:

    static public function DrawStippledShape2(g:Graphics,
points:Array, pattern:Array=null, alphas:Array=null,
colors:Array=null, thicknesses:Array=null, offset:Number=0):void
    {
      g.moveTo(points[0].x, points[0].y);
      var pat2:Array = [];
      var patsum:Number = 0;
      for each (var p:Number in pattern){
        patsum += p;
      }
      for (var i:int = 0 ; i < pattern.length ; i++){
        pat2[i] = pattern[i] / patsum * 255;
      }
      
      for (var i:int = 1 ; i <points.length ; i++){
        var p1:Point = points[i-1];
        var p2:Point = points[i];
        
        
        var m:Matrix = new Matrix;
        var ptemp:Point = p2.subtract(p1);
        var rot:Number = (Math.atan2(ptemp.y, ptemp.x));   
  
        m.createGradientBox(patsum,patsum,0,offset, offset);
        
        
        //note(rot.toString());
        m.rotate(rot);       
  
        g.lineStyle(5,0);
        
        g.lineGradientStyle( GradientType.LINEAR, colors, alphas,
pat2, m, SpreadMethod.REFLECT, InterpolationMethod.LINEAR_RGB);
        
        //g.beginGradientFill(GradientType.RADIAL, [0xFF0000,
0x00FF00], [1,1], [0,128],m);
        
        g.lineTo(p2.x, p2.y);
      }
    }

Reply via email to