Flex图片层次控制

<?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>
虽然简单,但也是基础。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值