所以我一直在环顾四周,我尝试了一些不同的东西,似乎仍然无法使用随机颜色生成器来处理这个用户绘制的线条。这是我正在处理用户绘制线的代码。
var myshape:Shape;
myshape = new Shape();
myshape.graphics.lineStyle(8, 0x99CC33);
myshape.filters = [new BlurFilter()];
function activateDraw(event:MouseEvent):void{
myshape.graphics.moveTo(mouseX, mouseY);
addChild(myshape);
stage.addEventListener(MouseEvent.MOUSE_MOVE, lineDraw);
stage.addEventListener(MouseEvent.MOUSE_UP, stopDraw);
}
function lineDraw(event:MouseEvent):void{
myshape.graphics.lineTo(mouseX, mouseY);
event.updateAfterEvent();
}
function stopDraw(event:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, lineDraw);
stage.removeEventListener(MouseEvent.MOUSE_UP, stopDraw);
myshape.graphics.clear();
myshape.graphics.lineStyle(12, 0x99CC33);
}
答案 0 :(得分:0)
想出来了!
var myshape:Shape;
myshape = new Shape();
myshape.graphics.lineStyle(8, Math.random() * 0xFFFFFF);
myshape.filters = [new BlurFilter()];
function activateDraw(event:MouseEvent):void{
myshape.graphics.moveTo(mouseX, mouseY);
addChild(myshape);
stage.addEventListener(MouseEvent.MOUSE_MOVE, lineDraw);
stage.addEventListener(MouseEvent.MOUSE_UP, stopDraw);
}
function lineDraw(event:MouseEvent):void{
myshape.graphics.lineTo(mouseX, mouseY);
event.updateAfterEvent();
}
function stopDraw(event:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, lineDraw);
stage.removeEventListener(MouseEvent.MOUSE_UP, stopDraw);
myshape.graphics.clear();
myshape.graphics.lineStyle(8, Math.random() * 0xFFFFFF);
}