【问题标题】:Get flex component id using Mouse event action使用鼠标事件操作获取 flex 组件 id
【发布时间】:2015-04-16 14:10:46
【问题描述】:

在 flex 应用程序中如何使用鼠标事件获取特定显示组件的 ID。例如,如果我想获取按钮的 ID,当我单击按钮时应该显示它

【问题讨论】:

    标签: actionscript-3 apache-flex mxml


    【解决方案1】:

    event.currentTarget.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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-16
      • 2011-01-07
      • 2023-01-24
      • 2011-08-31
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      相关资源
      最近更新 更多