flex 画图,操作图形例子,(图表,曲线,都可用此思路)

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  applicationComplete="init()">

<mx:Style>
	ToolTip{
		background-color:#FFCCFF;
		font-size:12px;
	}
</mx:Style>
<mx:Script>
	<![CDATA[
	
	// 这个是画一个简单的图形并能清除他
	
	
		import mx.controls.ToolTip;
	
		import mx.printing.FlexPrintJob;
		import printView;
		import mx.core.UIComponent;
		import mx.controls.Alert;
		
		private var _sperite:Sprite; 
		private var _sperite2:Sprite; 
		private var tt:ToolTip = new ToolTip();

		private function init(){
			
			_sperite = new Sprite();//建立影片精灵 
			_sperite2 = new Sprite();//建立影片精灵 
			var uicomponent:UIComponent = new UIComponent();
			uicomponent.addChild(_sperite);
			uicomponent.addChild(_sperite2);
			box.addChild(uicomponent);
			doDraw();
		}
		
		function doDraw():void{
			tt.text="加饭要吃饱呀";
			tt.width = 120;
			tt.height = 120;
			tt.x = 616;
			tt.y = 42;
			
			tt.visible = false;
			button1.addChild(tt);
			
			_sperite.graphics.lineStyle(1,0xA8A8A8,1);
			_sperite.graphics.moveTo(0,0);
			_sperite.graphics.lineTo(100,100);
			
			_sperite2.graphics.lineStyle(1,0xFFCC99,1);
			_sperite2.graphics.beginFill(0xFFCC99,1);
			_sperite2.graphics.drawCircle(50,50,20);
			_sperite2.graphics.endFill();
			_sperite2.addChild(tt); 
			_sperite2.addEventListener(MouseEvent.MOUSE_OVER,showTip);
			_sperite2.addEventListener(MouseEvent.MOUSE_OUT,hideTip);
		}
		function showTip(event:MouseEvent){
			tt.visible = true;
			tt.x = event.localX;
			tt.y = event.localY;
			this.graphics.beginFill(0x6699FF,1);
			this.graphics.endFill();
		}
		function hideTip(event:MouseEvent){
			tt.visible = false;
		}
		function doClean():void{
			_sperite2.graphics.clear();
		}
	]]>
</mx:Script>
	<mx:Button x="616" y="42" label="清除" id="button1" click="doClean()"/>
	<mx:Canvas id="canvas" x="10" y="42" height="400" width="500" backgroundColor="#FFFFCC" >	
		<mx:Canvas id="box" x="0" y="0"  ></mx:Canvas>
	</mx:Canvas>
	<mx:Label x="147" y="16" text="这个是画一个简单的图形并能清除他" fontSize="12"/>
	
</mx:Application>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值