`
hereson
  • 浏览: 1430097 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Event handlers in Repeater components

    博客分类:
  • flex
阅读更多
<?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>

分享到:
评论

相关推荐

    Javascript Event Handlers.zip

    Javascript Event Handlers

    Web event handlers

    总结了IE 5 ,页面的所有事件 Dom Event Handlers/Dom 事件处理函数

    (转)Developer's Guide - Event Handlers

    NULL 博文链接:https://qtlkw.iteye.com/blog/1887380

    Eclipse下的可视化界面设计WindowBuilder插件所有版本打包

    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.

    Disruptor3.x Disruptor使用方式

    EventHandler&lt;Event&gt;[] eventHandlers=new DisruptorEventHandler[]{new DisruptorEventHandler()}; DisruptorPublisher dp=new DisruptorPublisher(1024, eventHandlers); dp.start(); for (int i = 0; true;...

    Rx.NET in Action

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

    flexpaper_handlers.js

    flexpaper_handlers.jsflexpaper_handlers.jsflexpaper_handlers.js

    Data-Access---Custom-Data-Binding-Format-Handlers_back

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

    Reactive Programming in Kotlin PDF

    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

    handlers.js

    asp.net mvc2资料

    All application logic resides in these event handlers: logic to accept and validate user input, to perform data access and storage, and to provide feedback by updating the UI. The whole application ...

    Integrating and Extending BIRT 2nd Edition

    Chapter 11 Working with Chart Event Handlers Chapter 12 Accessing Data Programmatically Part IV Integrating BIRT Functionality into Applications Chapter 13 Understanding the BIRT APIs Chapter 14 ...

    What Is a Compact Framework Program

    The last chapter looked at the ...event handlers. We also explain the relationship between the code generated for you by the Visual Studio .NET Forms Designer and the code that you must write yourself.

    Dart 1 for Everyone(Pragmatic,2014)

    The MVC project chapters dumped the old JavaScript-like event handlers for the sleek new streams interface, and the chapter on testing reflects the extensive changes in testing now available in Dart....

    React Bits 中文版

    ✔ Event Handlers ✔ Flux Pattern ✔ One Way Data Flow ✔ Presentational vs Container ✔ Third Party Integration ✔ Passing Function To setState() ✔ Decorators ✔ Feature Flags ✔ Component Switch ✔...

    Ch02_Preview_vb

    event handlers. We also explain the relationship between the code generated for you by the Visual Studio .NET Forms Designer and the code that you must write yourself. vb版的哈,别下错了

    OSSEventManager 1.0

    OSSEventManager is short for "Office SharePoint Server 2007 Event handler Manager", it's a winform tool to deploy some list item event handlers into SharePoint lists. 本工具用于部署SharePoint 2007列表...

    Adding-Event-Handlers_lesson:学习如何使用事件处理程序和JavaScript的.addEventListener()方法的课程

    Adding-Event-Handlers_lesson 学习如何使用事件处理程序和JavaScript的.addEventListener()方法的课程

Global site tag (gtag.js) - Google Analytics