Flex图片层次控制

来源:互联网 发布:jquery each 数组 编辑:程序博客网 时间:2024/06/10 00:13
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"    xmlns:s="library://ns.adobe.com/flex/spark"  width="800" height="600"   xmlns:mx="library://ns.adobe.com/flex/mx"  creationComplete="application1_creationCompleteHandler(event)"><fx:Script><![CDATA[import mx.events.FlexEvent;protected function application1_creationCompleteHandler(event:FlexEvent):void{var circle1:Sprite = new Sprite();// 创建3个圆circle1.graphics.beginFill(0xff00ff);circle1.graphics.drawCircle(280,280,50);var circle2:Sprite = new Sprite();circle2.graphics.beginFill(0x12342f);circle2.graphics.drawCircle(340,280,50);var circle3:Sprite = new Sprite();circle3.graphics.beginFill(0xf123ff);circle3.graphics.drawCircle(320,320,50);UI.addChild(circle1);UI.addChild(circle2);UI.addChild(circle3);circle1.addEventListener(MouseEvent.CLICK,mouseClick);//添加鼠标事件circle2.addEventListener(MouseEvent.CLICK,mouseClick);circle3.addEventListener(MouseEvent.CLICK,mouseClick);}private function mouseClick(event:MouseEvent):void{var circle:Sprite = Sprite(event.target); 层次控制var topPosition:uint = UI.numChildren - 1;UI.setChildIndex(circle,topPosition);}]]></fx:Script><mx:UIComponent id="UI"></mx:UIComponent></s:Application>虽然简单,但也是基础。