Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 绘图功能,但仅在特定屏幕/页面上(actionscript3)_Actionscript 3_Flash_Actionscript_Drawing - Fatal编程技术网

Actionscript 3 绘图功能,但仅在特定屏幕/页面上(actionscript3)

Actionscript 3 绘图功能,但仅在特定屏幕/页面上(actionscript3),actionscript-3,flash,actionscript,drawing,Actionscript 3,Flash,Actionscript,Drawing,如何使绘图功能仅在应用程序的一个页面/屏幕上运行?例如,绘图功能只应出现在第15页。当“绘图”/“绘图”功能转到其他页面时,我应该怎么做才能使其不卡在屏幕上?(我正在试着做一个原型)谢谢 以下是我正在使用的绘图功能代码: var Line:Sprite = new Sprite(); addChild(Line); Line.graphics.lineStyle(3, 0x000000, 1 ); stage.addEventListener(MouseEvent.MOUSE_DOWN, mo

如何使绘图功能仅在应用程序的一个页面/屏幕上运行?例如,绘图功能只应出现在第15页。当“绘图”/“绘图”功能转到其他页面时,我应该怎么做才能使其不卡在屏幕上?(我正在试着做一个原型)谢谢

以下是我正在使用的绘图功能代码:

var Line:Sprite = new Sprite();
addChild(Line);
Line.graphics.lineStyle(3, 0x000000, 1 );

stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown1);
addEventListener(MouseEvent.MOUSE_UP, mouseUp1);

function mouseDown1(e:MouseEvent):void {
    Line.graphics.moveTo(e.stageX, e.stageY);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove1);
}

function mouseMove1(e:MouseEvent):void {
    Line.graphics.lineTo(e.stageX, e.stageY);
}

function mouseUp1(e:MouseEvent):void {
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove1);
}

要在
阶段
中绘制某些内容,您已经在
阶段
中添加了一些
MouseEvent
侦听器,因此要停止绘制,您只需删除这些侦听器并清除
图形
对象,当然,如果您需要的话,如下所示:

stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown1)
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUp1);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove1);

Line.graphics.clear();

希望能有所帮助。

Flash没有页面的概念。无论您决定是一个“页面”将是同一个地方,你将需要清除图纸。例如,如果您使用的是像页面这样的框架,那么当您更改框架时(
gotoAndStop()
等),您应该清除图形

要清除图形,可以删除
对象(使用
removeChild()
或时间轴上的关键帧),也可以使用
Line.graphics.clear()