as3.0 怎么用按钮控制 删除选中的影片剪辑,影片剪辑是复制出来的。
删除下面代码复制出来的mymc0:buildingMC.addEventListener(MouseEvent.MOUSE_DOWN,copy);functioncopy...
删除下面代码复制出来的mymc0:
buildingMC.addEventListener(MouseEvent.MOUSE_DOWN,copy);
function copy(event:MouseEvent):void {
var flag = 1;
var mymc0: BuildingMC1 = new BuildingMC1();
addChild(mymc0);
也就是我选中哪个影片剪辑按一下删除按钮就能把它删除?
我只有这么多财富值了,希望好心人帮忙解答下!不甚感激! 展开
buildingMC.addEventListener(MouseEvent.MOUSE_DOWN,copy);
function copy(event:MouseEvent):void {
var flag = 1;
var mymc0: BuildingMC1 = new BuildingMC1();
addChild(mymc0);
也就是我选中哪个影片剪辑按一下删除按钮就能把它删除?
我只有这么多财富值了,希望好心人帮忙解答下!不甚感激! 展开
2011-07-27
展开全部
import flash.utils;
删除按钮.addEventListener(MouseEvent.CLICK,copy);
function copy(event:MouseEvent):void {
stage.addEventListener(MouseEvent.CLICK,fun1);
}
function fun1(_evt:MouseEvent):void{
stage.removeEventListener(MouseEvent.CLICK,fun1);
var arr:Array = stage.getObjectsUnderPoint(new Point(_evt.stageX,_evt.stageY));
if(arr){
for(var i:uint=0;i<arr.length;i++){
if(getQualifiedClassName(arr[i]) == "BuildingMC1"){
Sprite(arr[i].parent).removeChild(arr[i]);
return;
}
}
}
}
大概的代码就是这样
删除按钮.addEventListener(MouseEvent.CLICK,copy);
function copy(event:MouseEvent):void {
stage.addEventListener(MouseEvent.CLICK,fun1);
}
function fun1(_evt:MouseEvent):void{
stage.removeEventListener(MouseEvent.CLICK,fun1);
var arr:Array = stage.getObjectsUnderPoint(new Point(_evt.stageX,_evt.stageY));
if(arr){
for(var i:uint=0;i<arr.length;i++){
if(getQualifiedClassName(arr[i]) == "BuildingMC1"){
Sprite(arr[i].parent).removeChild(arr[i]);
return;
}
}
}
}
大概的代码就是这样
更多追问追答
追问
我用trace(getQualifiedClassName(arr[i])) 测试,我选中我复制的那个影片然后再按删除按钮,输出窗口输出的是flash.display::Shape 这个类,不是“BuildingMC1”;为什么呢?
追答
var mymc0: BuildingMC1 = new BuildingMC1();
mymc0.mouseChildren = false;
addChild(mymc0);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询