Posted By

IsoJon on 03/11/10


Tagged

line dotted


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

davidino1978
tombarc


Create Dotted Line (made of any shape/MC)


 / Published in: ActionScript 3
 

You can replace the library item with whatever you want, or draw a shape in actionscript to use.

TweenMax is used in this snippet, get it here: http://www.greensock.com/tweenmax/ and thank Jack Doyle for being great by donating.

  1. // Right click the movieclip you wish to use in the library and
  2. // change the linkage name to "Dot" or create your own custom class.
  3.  
  4. // TweenMax is used in this snippet, get it here: http://www.greensock.com/tweenmax/
  5. // and thank Jack Doyle for being great by donating.
  6.  
  7.  
  8. import com.greensock.TweenMax;
  9. import com.greensock.easing.*;
  10.  
  11. var dotLength : int = 870; // the length that you'd like the dot to be
  12. createDotLine( dotLength, 50, 100 ); // place this anywhere, this creates your dot,
  13. // it takes three parameters: length + x,y of line
  14.  
  15. function createDotLine( dL:int, sX:int, sY:int ) : void
  16. {
  17. var dotSprite : Sprite = new Sprite();
  18. dotSprite.y = sY;
  19. dotSprite.x = sX;
  20. addChild(dotSprite);
  21.  
  22. while ( dotSprite.width <= dL )
  23. {
  24. var w : int = dotSprite.width;
  25. var d : Sprite = new Dot();
  26. d.x = w;
  27. dotSprite.addChild( d );
  28. }
  29.  
  30. for ( var i : int = 0; i < dotSprite.numChildren; i++)
  31. {
  32. var dS = dotSprite.getChildAt( i );
  33. var plusMinusY : int;
  34. if ( i % 2 == 0 )
  35. {
  36. plusMinusY = dS.y - 50;
  37. } else {
  38. plusMinusY = dS.y + 50;
  39. }
  40.  
  41. TweenMax.from( dS, .7, { alpha:0, y:plusMinusY, x:dS.x - 40, delay:i * .01, ease:Expo.easeInOut });
  42. }
  43. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: adrianparr on March 16, 2010

Note: The import statements shown are for an old version of TweenMax. The package structure has changed in the latest version. It should now be ...

import com.greensock.*; import com.greensock.easing.*;

Posted By: adrianparr on March 16, 2010

When I run your code I get the following compile error ...

Scene 1, Layer 'Layer 1', Frame 1, Line 18 1180: Call to a possibly undefined method Dot.

Shouldn't there be a Dot class as well.

Posted By: IsoJon on July 2, 2010

The Dot would be your library item with the linkage dot, or you could make your own custom class... I'll update the snippet with a comment to reflect that.

Posted By: viaria on September 20, 2011

that would be nice. waiting for that.

You need to login to post a comment.