如何检测是否在 Flex Spinner 组件中单击了递增或递减按钮?
问问题
534 次
3 回答
1
numericStepper 创建完成后,获取按钮并监听事件:
<?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">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function numericstepper1_creationCompleteHandler(event:FlexEvent):void
{
var stepper:NumericStepper = NumericStepper(event.target);
stepper.incrementButton.addEventListener(MouseEvent.CLICK, onIncrementClickHandler, false, 0, true);
stepper.decrementButton.addEventListener(MouseEvent.CLICK, onDecrementClickHandler, false, 0, true);
}
protected function onIncrementClickHandler(event:MouseEvent):void
{
Alert.show("incrementButton click");
}
protected function onDecrementClickHandler(event:MouseEvent):void
{
Alert.show("decrementButton click");
}
]]>
</fx:Script>
<s:NumericStepper creationComplete="numericstepper1_creationCompleteHandler(event)" />
</s:Application>
于 2013-04-24T08:15:24.067 回答
0
protected function spinnerClick(event:MouseEvent):void
{
Alert.show(event.target.id);
// will show 'incrementButton' or 'decrementButton'
}
<s:Spinner click="spinnerClick(event)"/>
于 2013-04-24T15:12:56.997 回答