flex BorderImage

package ce.control
{
	import mx.controls.Image;
	
	//边框颜色
	[Style(name="borderColor", type="uint", format="Color", inherit="no")]
	//边框宽度
	[Style(name="borderWidth", type="Number", format="Length", inherit="no")]
	//边框透明度
	[Style(name="borderAlpha", type="Number", format="Length", inherit="no")]
	
	public class BorderImage extends Image
	{
		public function BorderImage()
		{
			super();
		}
	
		override protected function updateDisplayList(w: Number, h: Number): void
		{
			super.updateDisplayList(w,h);
			graphics.clear();
			
			graphics.lineStyle(getStyle("borderWidth"), getStyle("borderColor"), getStyle("borderAlpha"), false);
		
			var x: Number =- (getStyle("borderWidth") / 2);
			var y: Number =- (getStyle("borderWidth") / 2);
			var width: Number = contentWidth + getStyle("borderWidth");
			var height: Number= contentHeight + getStyle("borderWidth");
			
			graphics.drawRect(x, y, width, height);		
		}
	}
}
<?xml version="1.0"?>
<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
	xmlns:ce="ce.control.*" 
	backgroundColor="#000000"
	layout="absolute">
	
	<!--
	http://feuyeux.iteye.com/blog/260606
	-->
	
    <ce:BorderImage 
    	borderAlpha="{aBar.value}" 
    	borderWidth="{wBar.value}" 
    	borderColor="{colorTool.selectedColor}" 
    	source="http://img.mp.sohu.com/upload/20170605/ef76627b70f246d39fdd523c95965771_th.png" 
    	width="258" height="229" x="180" y="62"/>
    	
    <mx:Label x="180" y="327" text="请选择边框颜色" color="#FDFDFD" fontSize="16"/>
    <mx:Label x="180" y="391" text="请选择边框宽度" color="#FDFDFD" fontSize="16"/>
    <mx:Label x="377" y="391" text="请选择边框透明度" color="#FDFDFD" fontSize="16"/>
    
    <mx:ColorPicker x="305" y="327" color="#FDFDFD" id="colorTool"/>
    <mx:VSlider x="525" y="255" minimum="0" maximum="1" id="aBar" />
    <mx:HSlider x="180" y="423" minimum="0" maximum="6" id="wBar"/>
    	
</mx:Application>

参考人家的,http://feuyeux.iteye.com/blog/260606







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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值