zoukankan      html  css  js  c++  java
  • 【AS3代码】深度的设置

    package
    {
        import com.ui.Ball;
        
        import flash.display.Sprite;

        public class Main extends Sprite
        {    
            var a:Ball = new Ball(0x000000,20);
            var b:Ball = new Ball(0x4c1b1b,20);
            var c:Ball = new Ball(0xf6e497,20);
            var d:Ball = new Ball(0xfcfae1,20);
            var e:Ball = new Ball(0xbd8d46,20);
            
            public function Main():void
            {
                init();
            }
            private function init():void
            {
                a.x = 100;
                a.y = 100;
                b.x = 120;
                b.y = 120;
                c.x = 140;
                c.y = 140;
                d.x = 160;
                d.y = 160;
                e.x = 180;
                e.y = 180;
                
                this.addChild(a);    //a深度0(最底层)
                this.addChild(c);    //c深度1
                this.addChild(e);    //e深度2(最上层)
                
                //设置b的深度为1后,c和e深度自动向后+1
                this.addChildAt(b,1);            
                
                trace(this.getChildIndex(a));    //a深度0
                trace(this.getChildIndex(c));    //c深度2
                trace(this.getChildIndex(e));    //e深度3
                
                this.addChild(d);
                
                //直接调换可视对象d和e的深度(调换后深度a0,b1,c2,d3,e4)
                this.swapChildren(d,e);
                
                //将倒数第一位的深度和倒数第二位深度上的可是对象对调
                this.swapChildrenAt((this.numChildren-2),(this.numChildren-1));        
                
                //将c置顶
                this.setChildIndex(c,this.numChildren-1);
                
            }
            
        }
    }
  • 相关阅读:
    全网解析视频接口自行测试
    emlog博客的安装教程
    无需任何软件,简单步骤教你手机投屏到电脑
    关于Windows 10系统重置了但以前的office找不到了问题的解决方法
    java indexOf方法
    JAVA 线程 yield
    android sqlite 增删改[insert、up…
    socket error 错误类型列表
    armeabigcc:error trying to& ex…
    android setBackgroundColor
  • 原文地址:https://www.cnblogs.com/kingfly/p/2593626.html
Copyright © 2011-2022 走看看