2016-10-13 00:16:48 点击量:13 标签: 收藏本文
使用DisplayObectContainer类的setChildIndex()方法改变项目的位置,getChildIndex()和getChildAt()方法得到项目在显示列表中的位置。getChildIndex()返回当前对象的索引,getChildAt()返回当前对象的引用
- package {
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.MouseEvent;
- public class Sample1120 extends Sprite
- {
- public function Sample1120()
- {
- var arrColor:Array = [0xFF0000,0x00FF00,0x0000FF,0xFFFF00,0x00FFFF];
- stage.addEventListener(MouseEvent.CLICK,OnClick);
- for(var i:int=0; i<arrColor.length;i++)
- {
- var shape:Shape = AddElement(arrColor[i]);
- shape.x = i*3+20;
- shape.y = 20;
- }
- }
- private function AddElement(color:int):Shape
- {
- var shape:Shape = new Shape();
- shape.graphics.beginFill(color);
- shape.graphics.drawCircle(10,10,30);
- shape.graphics.endFill();
- this.addChild(shape);
- return shape;
- }
- private function OnClick(event:MouseEvent):void
- {
- this.setChildIndex(this.getChildAt(0),this.numChildren-1);
- }
- }
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室