我想知道如何在movieclip []数组中绘制线条:
movieclip myted
line myshape
for (var i:int = 0; i < myted.numChildren-1; i++) {
if (myted.getChildAt(i).hitTestPoint(mouseX,mouseY,true)) {
//drawingLine.transform.colorTransform=pal_color;
}
}
答案 0 :(得分:1)
使用Graphics实例执行的所有绘图都基于带有直线和曲线的基本绘图。因此,必须使用相同的一系列步骤执行所有ActionScript绘图:
定义一行和填充样式:
var myShape:Shape = new Shape();
myShape.graphics.lineStyle(2, 0x990000, .75);
myShape.graphics.moveTo(100, 100);
myShape.graphics.lineTo(200, 200);
movieClipInstanceName.addChild(myShape);
答案 1 :(得分:0)
“http://i.stack.imgur.com/ESfzi.png” 谢谢 不明白不工作? 不能在movieclip里面工作原始线! 当鼠标在泰迪内移动时,在movieclip S1 .. s27中绘制线条 ////////////////
var drawingLine:MovieClip = new MovieClip();
s.addChild(drawingLine);
//2.
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
//3.
function MouseDown(event:MouseEvent):void{
drawingLine.graphics.lineStyle(3);
drawingLine.graphics.moveTo(mouseX, mouseY);
s.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}
//4.
function MouseMove(event:MouseEvent):void{
drawingLine.graphics.lineTo(mouseX, mouseY);
for (var i:int = 0; i < teddy.numChildren-1; i++) {
if (teddy.getChildByName("s"+i).hitTestPoint(mouseX,mouseY,true)) {
pal_color=teddy.getChildAt(i).transform.colorTransform;
pal_color.color=colors[current_color];
teddy.getChildByName("s"+i).transform.colorTransform=pal_color;
}
}
}
//5.
function MouseUp(event:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}
public function on_teddy_click(e:MouseEvent):void {
for (var i:int = 0; i < teddy.numChildren-1; i++) {
if (teddy.getChildByName("s"+i).hitTestPoint(mouseX,mouseY,true)) {
pal_color=teddy.getChildAt(i).transform.colorTransform;
pal_color.color=colors[current_color];
teddy.getChildByName("s"+i).transform.colorTransform=pal_color;
}
}
}
/////////////////////////////////
sample 2:
not Draw line inside movieclip "S"
var drawingLine:MovieClip = new MovieClip();
s.addChild(drawingLine);
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
function MouseDown(event:MouseEvent):void{
drawingLine.graphics.lineStyle(3);
drawingLine.graphics.moveTo(mouseX, mouseY);
s.addEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}
function MouseMove(event:MouseEvent):void{
drawingLine.graphics.lineTo(mouseX, mouseY);
}
function MouseUp(event:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, MouseMove);
}