ActionScript LineStyle 颜色过早更改
我试图在彼此旁边绘制线条,但在分配第二种颜色之前,第一个颜色组的最后一条线采用第二个颜色组的颜色。谁能解释一下吗?
function drawCorner()
{
var corner:Sprite = new Sprite();
corner.graphics.beginFill(0x0, 1.0);
corner.graphics.drawRect(0, 0, 20, 20);
corner.graphics.lineStyle(0, 0x00FF00, 1.0);
corner.graphics.moveTo(1, 13);
corner.graphics.lineTo(13, 1);
corner.graphics.moveTo(6, 13);
corner.graphics.lineTo(13, 6);
corner.graphics.moveTo(11, 13);
corner.graphics.lineTo(13, 11);
corner.graphics.lineStyle(0, 0xFF00FF, 1.0);
corner.graphics.moveTo(0, 13);
corner.graphics.lineTo(13, 0);
corner.graphics.moveTo(5, 13);
corner.graphics.lineTo(13, 5);
corner.graphics.moveTo(10, 13);
corner.graphics.lineTo(13, 10);
corner.graphics.endFill();
addChild(corner);
}
i'm attempting to draw lines beside each other, but the last line from the first color group takes on the color from the second color group before the second color is assigned. can anyone explain this?
function drawCorner()
{
var corner:Sprite = new Sprite();
corner.graphics.beginFill(0x0, 1.0);
corner.graphics.drawRect(0, 0, 20, 20);
corner.graphics.lineStyle(0, 0x00FF00, 1.0);
corner.graphics.moveTo(1, 13);
corner.graphics.lineTo(13, 1);
corner.graphics.moveTo(6, 13);
corner.graphics.lineTo(13, 6);
corner.graphics.moveTo(11, 13);
corner.graphics.lineTo(13, 11);
corner.graphics.lineStyle(0, 0xFF00FF, 1.0);
corner.graphics.moveTo(0, 13);
corner.graphics.lineTo(13, 0);
corner.graphics.moveTo(5, 13);
corner.graphics.lineTo(13, 5);
corner.graphics.moveTo(10, 13);
corner.graphics.lineTo(13, 10);
corner.graphics.endFill();
addChild(corner);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我不完全确定为什么发生这种情况,但它发生是因为您放置了
corner.graphics.endFill();
在drawRect之后立即调用endFill,问题就解决了。
While I am not entirely sure why this is happening, it is happening because of your placement of
corner.graphics.endFill();
Place the endFill call immediately after the drawRect and the problem is resolved.
您也可以
在更改 lineStyle 之前放置 。
You can also put the
before you change lineStyle.