removeChild使用不正确?
我只是想在双击时从舞台上删除影片剪辑
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
public class Main extends MovieClip{
var thingeh:Things;
public function Main() {
thingeh = new Things;
stage.addEventListener(MouseEvent.CLICK, onClick);
stage.addEventListener(MouseEvent.DOUBLE_CLICK, onDouble);
}
public function onClick(event:MouseEvent)
{
addChild(thingeh);
}
public function onDouble(event:MouseEvent)
{
if(thingeh)
removeChild(thingeh);
}
}
}
I'm just trying to remove a movie clip from the stage upon double clicking
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
public class Main extends MovieClip{
var thingeh:Things;
public function Main() {
thingeh = new Things;
stage.addEventListener(MouseEvent.CLICK, onClick);
stage.addEventListener(MouseEvent.DOUBLE_CLICK, onDouble);
}
public function onClick(event:MouseEvent)
{
addChild(thingeh);
}
public function onDouble(event:MouseEvent)
{
if(thingeh)
removeChild(thingeh);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另外,您可能希望在构造函数中使用
doubleClickEnabled = true
。请注意,
MouseEvent.CLICK
与MouseEvent.DOUBLE_CLICK
事件一起被触发两次。Also, You may want
doubleClickEnabled = true
within your constructor.Do note,
MouseEvent.CLICK
gets fired TWICE along with aMouseEvent.DOUBLE_CLICK
event.