Created
September 22, 2014 00:08
-
-
Save mattlundstrom/c8dec3b8cae042285907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| drawDottedLine( new Point( 0, 0 ), new Point( 500, 100 ), 0x000000, 1, 3, 0, 1 ); | |
| function drawDottedLine( _p1:Point, _p2:Point, _color:uint = 0x000000, _thickness:Number = 1, _gap:Number = 10, _offset:Number = 0, _percent:Number = 1 ):void{ | |
| var line:MovieClip = new MovieClip(); | |
| addChild( line ); | |
| var distance:Number = distance( _p1, _p2 ); | |
| var increments:int = distance / _gap; | |
| var gfx:Graphics = line.graphics; | |
| gfx.beginFill( _color, _thickness ); | |
| for( var i:int = 0; i< increments; i++ ) | |
| { | |
| var percetDrawn:Number = i * _gap / distance; | |
| var _x:Number = lerp( _p1.x, _p2.x, percetDrawn ); | |
| var _y:Number = lerp( _p1.x, _p2.x, percetDrawn ); | |
| gfx.drawCircle( _x, _y, 2 ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment