<?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" minWidth="955" minHeight="600"
creationComplete="onCreationCompleteHandler(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.binding.utils.BindingUtils;
import mx.events.FlexEvent;
private var mX:Number;
private var mY:Number;
private var isDown:Boolean = false;
[Bindable] public var _lineSize:int =3;
[Bindable] public var _lineColor:uint = 0Xff0000;
private function onMouse_downHandler(e:MouseEvent):void{
isDown = true;
mX = myPanel.mouseX;
mY = myPanel.mouseY;
}
private function onMouse_upHandler(e:MouseEvent):void{
isDown = false;
}
private function onMouse_moveHandler(e:MouseEvent):void{
if(isDown){
var x:Number = myPanel.mouseX;
var y:Number = myPanel.mouseY;
myPanel.graphics.lineStyle(_lineSize,_lineColor,1);
myPanel.graphics.moveTo(mX,mY);
myPanel.graphics.lineTo(x,y);
mX = x;
mY = y;
}
}
protected function onCreationCompleteHandler(event:FlexEvent):void
{
myPanel.addEventListener(MouseEvent.MOUSE_DOWN,onMouse_downHandler);
myPanel.addEventListener(MouseEvent.MOUSE_MOVE,onMouse_moveHandler);
myPanel.addEventListener(MouseEvent.MOUSE_UP,onMouse_upHandler);
BindingUtils.bindProperty(this,"_lineSize",hs,"value");
BindingUtils.bindProperty(this,"_lineColor",cp,"selectedColor");
}
]]>
</fx:Script>
<mx:Panel width="100%" height="100%">
<s:Group id="myPanel" x="113.5" y="83" width="100%" height="90%"
buttonMode="true">
</s:Group>
<s:Button label="清空" click="myPanel.graphics.clear();"/>
<mx:HSlider id="hs" value="{_lineSize}"/>
<mx:ColorPicker id="cp" selectedColor="{_lineColor}"/>
</mx:Panel>
</s:Application>
Flex 荧光笔
最新推荐文章于 2022-11-19 10:35:44 发布