as3 怎样设置层级?本人是很菜的菜鸟,希望得到具体的代码解答,谢谢
2个回答
展开全部
//新建影片剪辑。链接属性-类名为Circle。看你能看懂不。
var circle1:Circle=new Circle();
var circle2:Circle=new Circle();
var circle3:Circle=new Circle();
circle1.x=300;
circle1.y=250;
circle2.x=250;
circle2.y=200;
circle3.x=300;
circle3.y=200;
addChild(circle1);
addChild(circle2);
addChild(circle3);
circle1.addEventListener(MouseEvent.CLICK,dian);
circle2.addEventListener(MouseEvent.CLICK,dian);
circle3.addEventListener(MouseEvent.CLICK,dian);
function dian(event:MouseEvent):void
{ //numChildren属性显示该容器的对象数目,从0开始
//setChildIndex方法设置对象显示的深层,0是最里面,最大的数在最外面
//event.currentTarget指的是MovieClip类的显示对象。
setChildIndex(MovieClip(event.currentTarget),numChildren-1);
}
var circle1:Circle=new Circle();
var circle2:Circle=new Circle();
var circle3:Circle=new Circle();
circle1.x=300;
circle1.y=250;
circle2.x=250;
circle2.y=200;
circle3.x=300;
circle3.y=200;
addChild(circle1);
addChild(circle2);
addChild(circle3);
circle1.addEventListener(MouseEvent.CLICK,dian);
circle2.addEventListener(MouseEvent.CLICK,dian);
circle3.addEventListener(MouseEvent.CLICK,dian);
function dian(event:MouseEvent):void
{ //numChildren属性显示该容器的对象数目,从0开始
//setChildIndex方法设置对象显示的深层,0是最里面,最大的数在最外面
//event.currentTarget指的是MovieClip类的显示对象。
setChildIndex(MovieClip(event.currentTarget),numChildren-1);
}
更多追问追答
追问
不是很懂啊
追答
var yuan1:Sprite=new Sprite();
var yuan2:Sprite=new Sprite();
var yuan3:Sprite=new Sprite();
//画三个圆
yuan1.graphics.lineStyle(1,0xff0000);
yuan1.graphics.beginFill(0xff0000);
yuan1.graphics.drawCircle(100,100,50);
addChild(yuan1);
yuan2.graphics.lineStyle(1,0x00ff00);
yuan2.graphics.beginFill(0x00ff00);
yuan2.graphics.drawCircle(120,150,50);
addChild(yuan2);
yuan3.graphics.lineStyle(1,0x0000ff);
yuan3.graphics.beginFill(0x0000ff);
yuan3.graphics.drawCircle(130,130,50);
addChild(yuan3);
//添加事件
yuan1.addEventListener(MouseEvent.CLICK,dianji);
yuan2.addEventListener(MouseEvent.CLICK,dianji);
yuan3.addEventListener(MouseEvent.CLICK,dianji);
function dianji(event:MouseEvent)
{
setChildIndex(Sprite(event.currentTarget),numChildren-1)
}
//这个和上面那个一样,你直接进去试试看效果。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询