FLASH AS3做一个五子棋,点击MC复制并拖动已实现代码如下,可删除任何一个创建出来的MC高人能否给点思路? 5
但删除棋盘上任何一MC,未研究出来。高人能否给点思路,代码如下:importfl.events.*importflash.display.MovieClipimportf...
但删除棋盘上任何一MC,未研究出来。高人能否给点思路,代码如下:
import fl.events.*
import flash.display.MovieClip
import flash.display.Sprite
import flash.events.MouseEvent;
import flash.display.DisplayObject
var jblake:blake= new blake()
bblake.addEventListener(MouseEvent.CLICK,blakecopy);
function blakecopy(event:MouseEvent):void{
var jblake:blake= new blake();//生成多个MC
jblake.x=950
jblake.y=400
addChild(jblake);
jblake.startDrag();
jblake.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
jblake.stopDrag();
}
} 展开
import fl.events.*
import flash.display.MovieClip
import flash.display.Sprite
import flash.events.MouseEvent;
import flash.display.DisplayObject
var jblake:blake= new blake()
bblake.addEventListener(MouseEvent.CLICK,blakecopy);
function blakecopy(event:MouseEvent):void{
var jblake:blake= new blake();//生成多个MC
jblake.x=950
jblake.y=400
addChild(jblake);
jblake.startDrag();
jblake.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
jblake.stopDrag();
}
} 展开
展开全部
你想怎么删除?一般可以用removeChild();
若是在一定模式下,用鼠标点一下就删的话,可以以下方法:
const DELETE:String = "delete";//这个加在前面;
var mode:String="";//这个加在前面;
以下要修改一下:
function blakecopy(event:MouseEvent):void{
var jblake:blake= new blake();//生成多个MC
jblake.x=950
jblake.y=400
addChild(jblake);
jblake.startDrag();
jblake.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
jblake.addEventListener(MouseEvent.MOUSE_DOWN, fl_ReleaseToDelete_2);//增加的.
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
jblake.stopDrag();
}
function fl_ReleaseToDelete_2(event:MouseEvent):void
{
if(mode==DELETE){
removeChild(event.currentTarget);
}
}
}
若是在一定模式下,用鼠标点一下就删的话,可以以下方法:
const DELETE:String = "delete";//这个加在前面;
var mode:String="";//这个加在前面;
以下要修改一下:
function blakecopy(event:MouseEvent):void{
var jblake:blake= new blake();//生成多个MC
jblake.x=950
jblake.y=400
addChild(jblake);
jblake.startDrag();
jblake.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
jblake.addEventListener(MouseEvent.MOUSE_DOWN, fl_ReleaseToDelete_2);//增加的.
function fl_ReleaseToDrop_2(event:MouseEvent):void
{
jblake.stopDrag();
}
function fl_ReleaseToDelete_2(event:MouseEvent):void
{
if(mode==DELETE){
removeChild(event.currentTarget);
}
}
}
追问
removeChild(event.currentTarget);
这句报错了,1118: 属于 static 类型 Object 的值的隐式强制指令的目标可能是非相关类型 flash.display:DisplayObject。
removeChild();我试过了,删不了。设想用点击删除按钮,再点击所要删的MC,进行删除。
追答
改成:removeChild(event.currentTarget as blake );
需要转型.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询