Drag Line

Actionscript exercise with a line connecting movable movieClips.

Flash Example

[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2007/02/dragline.swf” width=”550″ height=”550″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

actionscript

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
// get x and y coordinates of the circles
var ax = _root.point1._x;
var ay = _root.point1._y;
var bx = _root.point2._x;
var by = _root.point2._y;
var cx = _root.point3._x;
var cy = _root.point3._y;

// draw line between them
_root.createEmptyMovieClip (“line”, 0);
with (_root.line){
lineStyle (1, 0x999999, 100);
moveTo (ax, ay);
lineTo (bx, by);
lineTo (cx, cy);
lineTo (ax, ay);
}
[/cc]

Download

dragLine.fla