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