1
在flex應用程序中如何使用鼠標事件獲取特定顯示組件的ID。例如,如果我想,當我按一下按鈕使用鼠標事件動作獲取flex組件ID
在flex應用程序中如何使用鼠標事件獲取特定顯示組件的ID。例如,如果我想,當我按一下按鈕使用鼠標事件動作獲取flex組件ID
做與event.currentTarget.id
這樣應該顯示的按鈕的ID:
<?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;
protected function niceButton_clickHandler(event:MouseEvent):void
{
Alert.show(" the button id is: "+event.currentTarget.id)
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:HGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">
<s:Button id="niceButton" label="click me" click="niceButton_clickHandler(event)" />
</s:HGroup>
</s:Application>