Reputation: 85
Lets say I have two objects, and I want to use action script to draw a line connecting them, which will update automatically as they are moved/ dragged. Can anyone show me how to do that, and also how to control line's parameters like colour, weight etc? Any answer would be highly appreciated!
Upvotes: 1
Views: 2789
Reputation: 5978
Let's say your two movieclips mc1
and mc2
share the same parent: mcParent
on an ENTER_FRAME event you would do:
mcParent.graphics.clear();
mcParent.graphics.lineStyle(1, 0, 1);
mcParent.graphics.moveTo(mc1.x, mc1.y);
mcParent.graphics.lineTo(mc2.x, mc2.y);
You can change the aspect of the stroke by changing the parameters of lineStyle.
Cheers!
Upvotes: 2