早教吧作业答案频道 -->其他-->
as3.0中的removeChild的用法我写了以下代码:varanxia:Boolean=falsestage.addEventListener(MouseEvent.MOUSEDOWN,hua)stage.addEventListener(MouseEvent.MOUSEUP,ting)stage.addEventListener(Event.ENTERFRAME,huahua)functionhua(event:MouseEve
题目详情
as3.0中的removeChild的用法
我写了以下代码:
var anxia:Boolean=false
stage.addEventListener(MouseEvent.MOUSE_DOWN,hua)
stage.addEventListener(MouseEvent.MOUSE_UP,ting)
stage.addEventListener(Event.ENTER_FRAME,huahua)
function hua(event:MouseEvent){
anxia=true
}
function ting(event:MouseEvent){
anxia=false
}
function huahua(event:Event){
if (anxia) {
var dian:Sprite=new Sprite()
dian.graphics.lineStyle(0,0x000000)
dian.graphics.beginFill(0x000000)
dian.graphics.drawCircle(0,0,2)
dian.x=mouseX
dian.y=mouseY
addChild(dian)
}
}
可以实现点击鼠标就开始画点直到放开鼠标,但我不懂如何实现放开鼠标后所有点都消失,用removeChild总不成功,只能删除最后放的那个点,具体应该怎样做?
我写了以下代码:
var anxia:Boolean=false
stage.addEventListener(MouseEvent.MOUSE_DOWN,hua)
stage.addEventListener(MouseEvent.MOUSE_UP,ting)
stage.addEventListener(Event.ENTER_FRAME,huahua)
function hua(event:MouseEvent){
anxia=true
}
function ting(event:MouseEvent){
anxia=false
}
function huahua(event:Event){
if (anxia) {
var dian:Sprite=new Sprite()
dian.graphics.lineStyle(0,0x000000)
dian.graphics.beginFill(0x000000)
dian.graphics.drawCircle(0,0,2)
dian.x=mouseX
dian.y=mouseY
addChild(dian)
}
}
可以实现点击鼠标就开始画点直到放开鼠标,但我不懂如何实现放开鼠标后所有点都消失,用removeChild总不成功,只能删除最后放的那个点,具体应该怎样做?
▼优质解答
答案和解析
改成这个样子:
var anxia:Boolean=false
var arr:Array = new Array();
stage.addEventListener(MouseEvent.MOUSE_DOWN,hua)
stage.addEventListener(MouseEvent.MOUSE_UP,ting)
stage.addEventListener(Event.ENTER_FRAME,huahua)
function hua(event:MouseEvent){
anxia=true
}
function ting(event:MouseEvent){
anxia=false
}
function huahua(event:Event){
if (anxia) {
var dian:Sprite=new Sprite()
dian.graphics.lineStyle(0,0x000000)
dian.graphics.beginFill(0x000000)
dian.graphics.drawCircle(0,0,2)
dian.x=mouseX
dian.y=mouseY
this.addChild(dian)
arr.push(dian);
}else{
if(arr.length > 0){
for(var i:int=0;i
var anxia:Boolean=false
var arr:Array = new Array();
stage.addEventListener(MouseEvent.MOUSE_DOWN,hua)
stage.addEventListener(MouseEvent.MOUSE_UP,ting)
stage.addEventListener(Event.ENTER_FRAME,huahua)
function hua(event:MouseEvent){
anxia=true
}
function ting(event:MouseEvent){
anxia=false
}
function huahua(event:Event){
if (anxia) {
var dian:Sprite=new Sprite()
dian.graphics.lineStyle(0,0x000000)
dian.graphics.beginFill(0x000000)
dian.graphics.drawCircle(0,0,2)
dian.x=mouseX
dian.y=mouseY
this.addChild(dian)
arr.push(dian);
}else{
if(arr.length > 0){
for(var i:int=0;i
看了 as3.0中的removeC...的网友还看了以下:
拼音首字组成的D.G.E.D.G.H.D.D.G.Q.O.B.C.A.B有点难度呵呵~ 2020-06-11 …
ABCDE5种有机物,分别由C、H或C、H、O组成,A氧化得到B,E氧化得到A,B易溶于水,D跟H 2020-06-12 …
已知一棵二叉树的中序序列和后序序列分别为c,b,e,d,a,h,g,i,j,f和c,e,d,b,h 2020-06-12 …
这5道题用波兰式表达(1)A*(B-C)+T/(D+E)-F/(S*H)(2)A/(B*C(E+F 2020-07-08 …
一个9位数abcdefghi满足:1.a+b+...+h+i=cd2.a(b+d-c)=243.( 2020-07-19 …
给出一棵树的逻辑结构T=(K,R),其中K={A,B,C,D,E,F,G,H,I,J}R={r}r 2020-07-22 …
关于电磁场与电磁波的问题为什么说理想导体(电导率-->∞)的E,D,B,H,有什么依据吗? 2020-07-29 …
该地质演化过程的正确排序是()A.d-e-g-f-b-a-h-cB.d-g-e-a-c-h-b-fC 2020-11-04 …
一个9位数abcdefghi满足:1.a+b+...+h+i=cd2.a(b+d-c)=243.(e 2020-11-19 …
A+B+C=84,D+E+F=111,H+I+J=138,A+D+H=124,B+E+I=148,C 2020-12-14 …