나는 잘 했는가. selectedIndex가 작동하지 않습니까?
<?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:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:ButtonBar
selectedIndex="2" width="400" height="300">
<s:dataProvider>
<s:ArrayCollection>
<fx:String>1</fx:String>
<fx:String>2</fx:String>
<fx:String>3</fx:String>
</s:ArrayCollection>
</s:dataProvider>
</s:ButtonBar>
</s:Application>
편집 :
이 당신을하는 데 도움이?
<?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" creationComplete="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
[Bindable]
private var dataSource:ArrayCollection = new ArrayCollection();
private function init():void
{
dataSource = new ArrayCollection(new Array("1","2","3"));
dataSource.addEventListener(CollectionEvent.COLLECTION_CHANGE, collectionEventChange);
dataSource.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
}
private function collectionEventChange(event:CollectionEvent):void
{
this.btnBar.selectedIndex = 2;
}
]]>
</fx:Script>
<s:ButtonBar id="btnBar" dataProvider="{dataSource}"
width="400" height="300" >
</s:ButtonBar>
</s:Application>
이전에는 사용하지 않았지만 버튼 막대에 selectedIndex가 있습니까? 플렉스 빌더 3을 사용하여 프레임 워크 3.0에서 잘 기억한다면 그랬습니다. –
시도했지만 ButtonBar의 첫 번째 버튼은 선택한 인덱스에 대한 값과 상관없이 선택되지 않았습니다. 기묘한! – Titus
hehe, 그것을 위해 데이터 공급자를 할당 한 후 넣을 지, 아니면 creationcomplete 이벤트에서 그냥 기술 문제를 피하기 위해 넣으십시오. 버튼을 클릭하고 myButtonBar.selectedIndex = 1과 같은 순간에 selectedIndex를 변경하려고 시도한 적이 있습니까? ; 작동하는 경우 .. selectedIndex가 전달되고 있다는 것입니다. 데이터 공급자가 할당되기 전에 .. 다음에 dataproviderChanged 이벤트가 있으면 할당하지 않아도됩니다. –