<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function clicker(cName:String):void {
foolabel.text=cName;
}
]]>
</mx:Script>
<mx:Label id="foolabel" text="foo"></mx:Label>
<mx:Model id="data">
<color>
<colorName>Red</colorName>
<colorName>Yellow</colorName>
<colorName>Blue</colorName>
</color>
</mx:Model>
<mx:ArrayCollection id="myAC" source="{data.colorName}"/>
<mx:Repeater id="myrep" dataProvider="{myAC}">
<mx:Button click="clicker(event.currentTarget.getRepeaterItem());"
label="{myrep.currentItem}"/>
</mx:Repeater>
</mx:Application>
After the user clicks the Yellow button, the application looks like this:
The code in the following example uses the getRepeaterItem()
method to display a specific URL for each Button control that the user clicks. The Button controls must share a common data-driven click handler, because you cannot use binding expressions inside event handlers. However, the getRepeaterItem()
method lets you change the functionality for each Button control.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
[Bindable]
public var dp:Array = [ { label: "Flex",
url: "http://www.adobe.com/flex" },
{ label: "Flash", url: "http://www.adobe.com/flash" } ];
]]>
</mx:Script>
<mx:ArrayCollection id="myAC" source="{dp}"/>
<mx:Repeater id="r" dataProvider="{myAC}">
<mx:Button label="{r.currentItem.label}" click="navigateToURL(new
URLRequest(event.currentTarget.getRepeaterItem().url));"/>
</mx:Repeater>
</mx:Application>
When executed, this example yields two buttons: one for Flex and one for Flash. When you click the button of your choice, the relevant product page loads in a new browser window.
<script type="text/javascript"></script>
分享到:
相关推荐
【标题】"Developer's Guide - Event Handlers" 是一篇关于开发者如何在编程中处理事件的指南。这个主题在软件开发,尤其是交互式应用开发中至关重要,因为它涉及到用户与应用程序的交互方式。事件处理器是程序响应...
总结了IE 5 ,页面的所有事件 Dom Event Handlers/Dom 事件处理函数
JavaScript事件处理器是JavaScript编程中的核心概念,用于处理用户与网页之间的交互。...理解并熟练掌握JavaScript事件处理机制对于创建动态和交互性强的网页至关重要。 事件是浏览器或JavaScript引擎在特定时刻触发的...
EventHandler<Event>[] eventHandlers=new DisruptorEventHandler[]{new DisruptorEventHandler()}; DisruptorPublisher dp=new DisruptorPublisher(1024, eventHandlers); dp.start(); for (int i = 0; true;...
Event Handling – add event handlers to your components. Menu Editing – visually create and edit menubars, menu items and popup menus. Morphing – convert one component type into another.
on with in-depth code examples to discover firsthand how to exploit the rich query capabilities that Rx provides and the Rx concurrency model that allows you to control both the asynchronicity of your...
foreach (var handler in _eventHandlers[eventType]) { ((Action)handler)(@event); } } } } // 使用示例 public class UserCreatedEvent : IEvent { public string UserName { get; set; } } public ...
foreach (var handler in _eventHandlers[eventType]) { ((Action)handler)(args); } } } } ``` 在这个实现中,`EventBus`类维护了一个字典 `_eventHandlers`,用于存储不同类型的事件及其对应的处理方法。`...
foreach (var handler in _eventHandlers[eventType]) { ((Action)handler)(eventData); } } } } ``` 在这个例子中,`EventBus` 类维护了一个事件处理器的字典,其中键是事件类型,值是对应的处理函数列表。`...
foreach (var handler in _eventHandlers[eventType]) { ((EventHandler)handler)(sender, args); } } } } ``` 5. **使用示例**:在实际应用中,发布者触发事件,事件总线负责分发,订阅者接收到事件并进行...
foreach (var handler in handlers) { ((Action)handler)(args); } } } } ``` 在这个类中,`Subscribe`方法用于订阅事件,`Unsubscribe`方法用于取消订阅,`Publish`方法用于发布事件。`TEvent`是泛型类型,...
foreach (var handler in eventHandlers) { ((Action)handler)(@event); } } } } ``` 现在,你可以创建事件发布者和订阅者。发布者只需调用`EventBus.Publish`来发送事件,而订阅者通过`EventBus.Subscribe`...
foreach (var handler in handlers) { ((Action)handler)(@event); } } } } } ``` 在实际应用中,我们可以在不同的类或组件中订阅和发布事件。例如,一个业务组件可以发布`MyCustomEvent`,而UI或其他组件...
《Flexpaper Handlers.js详解》 Flexpaper Handlers.js是Flexpaper文档查看器中的核心脚本文件,主要用于处理用户交互和各种事件。在深入探讨这个文件之前,我们先了解一下Flexpaper是什么。Flexpaper是一款强大的...
This application demonstrates how to use the Format and Parse event handlers when data binding Windows Form controls. The Format event fires when the data is transferred the data source to the bound ...
You will dive into advanced techniques such as manipulating time in data-flow, customizing operators and provider and how to Use the concurrency model to control asynchronicity of code and process ...
handlers.js
事件句柄(Event Handlers)是HTML 4.0引入的新特性,允许我们通过在HTML标签中添加特定属性来指定事件发生时的行为。例如,`onclick`属性会在用户点击元素时调用关联的JavaScript函数。以下是一些常见的事件句柄: ...