0
Folgende Anzeigen eine ComboBox mit dem Text "One Select":Kann ich eine bindbare Zeichenfolge für eine ComboBox-Eingabeaufforderung verwenden?
** Dies ist Pseudo-Code *
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:ComboBox prompt="Select One">
<mx:dataProvider>
<mx:Array>
<mx:Object label="Obj 1" />
<mx:Object label="Obj 2" />
<mx:Object label="Obj 3" />
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:Application>
jedoch folgende Anzeigen eine ComboBox mit dem Text "Ziel 1" (das Label des ersten Artikels):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
[Bindable]
private var promptText:String = "Select One";
]]>
</mx:Script>
<mx:ComboBox prompt="{promptText}">
<mx:dataProvider>
<mx:Array>
<mx:Object label="Obj 1" />
<mx:Object label="Obj 2" />
<mx:Object label="Obj 3" />
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:Application>
Warum kann ich keine Bindable String für die Eingabeaufforderung verwenden ???
Die Bindung erfolgt etwas später als die Komponentenerstellung. Ich vermute, dass die ComboBox standardmäßig das erste Element auswählt, wenn Sie keine Eingabeaufforderung angeben. Also, die ComboBox wird erstellt, validiert und wählt das erste Element, und dann wird die Bindung eingefügt. – joshtynjala
Ja, das macht Sinn. –