# Posted By

IsoJon on 03/11/10

# Statistics

Viewed 473 times
Favorited by 0 user(s)

# 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.

Copy this code and paste it in your HTML
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;
21.
22. while ( dotSprite.width <= dL )
23. {
24. var w : int = dotSprite.width;
25. var d : Sprite = new Dot();
26. d.x = w;
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. }