Flex4 ButtonBar 双击出现异常,意外吧,看看运行效果就明白了

Flex4 ButtonBar 双击出现异常,意外吧,看看运行效果就明白了



<?xml version="1.0" encoding="utf-8"?>
<!-- dpcontrols\sparkdpcontrols\SparkBBarEvent.mxml -->
<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">
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
    
    <fx:Script> 
        <![CDATA[ 
            import spark.events.IndexChangeEvent; 
 
            private function changeHandler(event:IndexChangeEvent):void { 
                myTA.text="Selected button index: " + 
                String(event.newIndex) + "\n" + 
                "Selected button label: " + 
                event.target.selectedItem; 
            } 
        
]]> 
    </fx:Script> 
    
    <s:ButtonBar 
        
change="changeHandler(event);">
        <mx:ArrayCollection>
            <fx:String>Flash</fx:String> 
            <fx:String>Director</fx:String> 
            <fx:String>Dreamweaver</fx:String> 
            <fx:String>ColdFusion</fx:String> 
        </mx:ArrayCollection>
    </s:ButtonBar> 
 
    <s:TextArea id="myTA" width="250" height="100"/> 
</s:Application>

我只点击第一个Button;

 

第一次点击:

Selected button index: 0
Selected button label: Flash

 

第二次点击:

lected button index: -1
Selected button label: undefined
 

posted @ 2011-09-23 15:00  Marksion  阅读(444)  评论(0编辑  收藏  举报