• 【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);
                
            }
            
        }
    }
  • 相关阅读:
    这一次,Google 终于对 Web 自动化下手了!
    移动端自动化 AutoJS 快速入门指南
    App 端自动化的最佳方案,完全解放双手!
    快过年了,如何使用 AutoJS 自动化快速抢微信红包!
    字节面试问我如何高效设计一个LRU,当场懵
    当前大厂笔试最高频的十道算法题
    coding game, 边打游戏边学编程,是一种怎么样的体验?
    一文详解面试常考的TopK问题
    动态规划,这几个问题最常见!
    备战蓝桥杯,你可以这么准备
  • 原文地址:https://www.cnblogs.com/kingfly/p/2593626.html
Copyright © 2020-2023  润新知