flex画直线示例

<img src="https://p-blog.csdn.net/images/p_blog_csdn_net/zhongweijian/EntryImages/20091221/1.jpg" mce_src="https://p-blog.csdn.net/images/p_blog_csdn_net/zhongweijian/EntryImages/20091221/1.jpg"/><span id="__caret">_</span><?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()"> <mx:Canvas id="paper" x="30" y="24" width="719" height="600"> <mx:Canvas id="Total" x="10" y="254" width="108" height="78" borderStyle="inset"> <mx:Button x="0" y="43" label="关键词导出" width="103" height="28"/> <mx:Text x="0" y="0" width="103" height="45" text="List PV:10000" fontSize="12"/> </mx:Canvas> <mx:Canvas id="LEV1_1" x="187" y="95" width="108" height="70" borderStyle="inset"> <mx:Button x="0" y="38" label="关键词导出" width="103" height="26"/> <mx:Text x="0" y="0" width="103" height="39" text="List PV:10000" fontSize="12"/> </mx:Canvas> <mx:Canvas id="LEV1_2" x="187" y="315" width="108" height="77" borderStyle="inset"> <mx:Button x="0" y="45" label="关键词导出" width="103" height="26"/> <mx:Text x="0" y="0" width="103" height="46" text="List PV:10000" fontSize="12"/> </mx:Canvas> <mx:Canvas id="LEV1_3" x="187" y="504" width="108" height="75" borderStyle="inset"> <mx:Button x="0" y="41" label="关键词导出" width="103" height="28"/> <mx:Text x="0" y="0" width="103" height="42" text="List PV:10000" fontSize="12"/> </mx:Canvas> <mx:Canvas id="LEV1_1_1" x="374" y="10" width="108" height="70" borderStyle="inset"> <mx:Button x="0" y="38" label="关键词导出" width="103" height="26"/> <mx:Text x="0" y="0" width="103" height="39" text="List PV:10000" fontSize="12"/> </mx:Canvas> <mx:Canvas id="LEV1_1_2" x="374" y="88" width="108" height="77" borderStyle="inset"> <mx:Button x="0" y="45" label="关键词导出" width="103" height="26"/> <mx:Text x="0" y="0" width="103" height="46" text="List PV:10000" fontSize="12"/> </mx:Canvas> <mx:Canvas id="LEV1_1_3" x="374" y="173" width="108" height="75" borderStyle="inset"> <mx:Button x="0" y="41" label="关键词导出" width="103" height="28" click="export(LEV1_1_3_text.text)"/> <mx:Text id="LEV1_1_3_text" x="0" y="0" width="103" height="42" text="List PV:10000" fontSize="12"/> </mx:Canvas> </mx:Canvas> <mx:Script> <!--[CDATA[ private function initApp():void{ paper.graphics.clear(); doDraw(Total, LEV1_1); doDraw(Total, LEV1_2); doDraw(Total, LEV1_3); doDraw(LEV1_1, LEV1_1_1); doDraw(LEV1_1, LEV1_1_2); doDraw(LEV1_1, LEV1_1_3); } private function createAll():void{ } private function export(text:String):void{ ExternalInterface.call("exportQueryXLS", text); } private function doDraw(source:Sprite,target:Sprite):void { var radius:Number = 10; var sourceCenter:Point = new Point(source.x + source.width,source.y + source.height/2); var targetCenter:Point = new Point(target.x ,target.y + target.height/2); var sin:Number = (sourceCenter.y - targetCenter.y)/(Math.sqrt(Math.pow(sourceCenter.x - targetCenter.x,2)+Math.pow(sourceCenter.y - targetCenter.y,2))); var radian:Number = Math.asin(sin); var degree:Number = radian*180/Math.PI; if(source.x < target.x) { if(degree == 0 ) { degree = 180; } if(degree > 0) { degree = 180 - degree; } if(degree < 0) { degree = 180 + degree * -1; } } degree += 90; radian = degree*Math.PI / 180; // var offsetX:Number = radius * Math.cos(radian); // var offsetY:Number = radius * Math.sin(radian); var offsetX:Number = 0; var offsetY:Number = 0; var sourcePointA:Point = new Point(sourceCenter.x + offsetX, sourceCenter.y + offsetY); var sourcePointB:Point = new Point(sourceCenter.x - offsetX, sourceCenter.y - offsetY); var targetPointA:Point = new Point(targetCenter.x + offsetX, targetCenter.y + offsetY); var targetPointB:Point = new Point(targetCenter.x - offsetX, targetCenter.y - offsetY); // paper.graphics.clear(); paper.graphics.lineStyle(1,0x333300,100); paper.graphics.moveTo(sourcePointA.x,sourcePointA.y); paper.graphics.lineTo(targetPointA.x,targetPointA.y); // paper.graphics.moveTo(sourcePointB.x,sourcePointB.y); // paper.graphics.lineTo(targetPointB.x,targetPointB.y); } ]]--> </mx:Script> </mx:Application>

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值