<?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"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="eventInit()">
<fx:Script>
<![CDATA[
import component.CGraphicBase;
import mx.managers.CursorManagerPriority;
import mx.managers.CursorManager;
[Bindable]
[Embed(source="img/tag.png")]
public var customCursor:Class;
private function eventInit():void{
var oItem:Object = new Object();
oItem.name = "testGraphic";
oItem.today = new Date();
//make Graphic
var oGraphic:
CGraphicBase = new CGraphicBase();
oGraphic.graphicInfo = oItem;
oGraphic.width =200;
oGraphic.height = 100;
oGraphic.x = 100;
oGraphic.y = 100;
oGraphic.color = 0xF19232;
oGraphic.toolTip = oItem.name + "-" + oItem.today.toString();
oGraphic.reFreshImage();
oGraphic.addEventListener(MouseEvent.MOUSE_OVER,eventMouseOver);
oGraphic.addEventListener(MouseEvent.MOUSE_OUT,eventMouseOut);
bc.addElement(oGraphic);
}
private function eventMouseOver(event:MouseEvent):void{
var oTarget:CGraphicBase = event.currentTarget as CGraphicBase;
CursorManager.setCursor(customCursor, CursorManagerPriority.HIGH, 3, 2);
}
private function eventMouseOut(event:MouseEvent):void{
var oTarget:CGraphicBase = event.currentTarget as CGraphicBase;
CursorManager.removeAllCursors();
}
]]>
</fx:Script>
<s:BorderContainer id="bc" width="100%" height="100%">
</s:BorderContainer>
</s:Application>
<?xml version="1.0" encoding="utf-8"?>
<s:Graphic xmlns:fx="
http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:common="common.*">
<fx:Script>
<![CDATA[
private var oInfo:Object;
public function set graphicInfo(value:Object):void{
oInfo = value;
}
public function get graphicInfo():Object{
return oInfo;
}
public function set color(value:uint):void{
ge.color = value;
}
public function set fillAlpha(value:Number):void{
ge.alpha = value;
}
public function get fillAlpha():Number{
return ge.alpha;
}
public function reFreshImage():void{
btnPath.data = "M 0 0 L "+this.width.toString()+" 0 L "+this.width.toString()+" "+this.height.toString()+" L 0 "+this.height.toString()+ " L 0 0 ";
}
]]>
</fx:Script>
<s:Path id="btnPath">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry id="ge" color="#F7CB3C" alpha=".6"/>
</s:LinearGradient>
</s:fill>
<s:stroke>
<s:SolidColorStroke id="outline" alpha="1" color="{ge.color}" weight="1" />
</s:stroke>
</s:Path>
</s:Graphic>