Copy link to clipboard
Copied
I am trying to create custom line or brushes that will be used to color in.
If I have 2 different movieclips, eg:
1. star
2. oval
How can i draw a line made out of these movieclips
I tried to addChild movieclips on the mouse move or on-enterframe but its not quick enough and leaves spaces in between.
I originally used a lineStyle, but now I need to replace that with a specific movieclip shape.
Any thoughts are welcome.
P
Copy link to clipboard
Copied
import flash.display.MovieClip;
import flash.events.MouseEvent
import flash.geom.Point;
var startPoint:Point = new Point();
var endPoint:Point = new Point();
stage.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, upHandler);
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler);
function downHandler(e:MouseEvent):void {
startPoint.x = mouseX;
startPoint.y = mouseY;
}
function upHandler(e:MouseEvent):void {
endPoint.x = mouseX;
endPoint.y = mouseX;
}
function moveHandler(e:MouseEvent):void {
//1.delete all stars you previously added to the displaylist
...
//2.get the endPoint
endPoint.x = mouseX;
endPoint.y = mouseX;
var s:Star = new Star();
drawObjectLineFromTo(s, startPoint, endPoint);
}
function getDistance(_p1:Point,_p2:Point):Number{
//use trigonometry to get the distance
...
}
function drawObjectLineFromTo(_mc:MovieClip,_p1:Point,_p2:Point):void{
var d:Number = getDistance(_p1, _p2);
var objectNumber:int = Math.round(d /_mc.width);
for (var i:int = 0; i < objectNumber; i++) {
//with a MovieClip exported to Star in your Library
var s:Star = new Star();
addChild(s);
//use trigonometry to place your stars evenly distributed betweeen _p1, _p2
...
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now