1

最新のフレックス SDK を使用して Flash Builder に取り組んでいます。

フォーム内で選択されたラジオ ボタンの値 radioButton を取得する際に問題があります。

<mx:Form id="form_new_contribution"> 
 <mx:FormItem label="Contribution type" includeIn="project_contributions">
  <mx:RadioButtonGroup id="myG" enabled="true" />
  <mx:RadioButton id="subtitle" label="subtitle" groupName="{myG}" value="subtitle"/>
  <mx:RadioButton id="note" label="notes / chapters" groupName="{myG}" value="note"/>
 </mx:FormItem>
</mx:Form>

機能は次のとおりです。

protected function button_add_new_clickHandler(event:MouseEvent):void{
 Alert.show(myG.selectedValue.toString());
}

私も試しました:

Alert.show(myG.selection.toString());

どちらのコードにもエラーが表示されます:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

そして、私が入れた場合にのみ機能する場合:

Alert.show(myG.toString());

それは警告します:オブジェクトRadioButtonGroup

ヒントをありがとう、そして長いメッセージでごめんなさい:)

4

2 に答える 2

2

ここで唯一間違っているのはgroupName、RadioButton のプロパティが文字列であり、中かっこで囲まれた への参照ではないことRadioButtonGroupです。

次のようにレンダリングする必要があります。

 <mx:RadioButton id="subtitle" label="subtitle" groupName="myG" value="subtitle"/>

いいえ

 <mx:RadioButton id="subtitle" label="subtitle" groupName="{myG}" value="subtitle"/>

または、groupプロパティを RBG 参照と共に使用することもできます。

 <mx:RadioButton id="subtitle" label="subtitle" group="{myG}" value="subtitle"/>
于 2010-05-13T16:53:57.143 に答える
0

このアラート機能をいつ呼び出すのですか?アラートが呼び出されたときにどちらのラジオボタンも選択されていないため、selectionとselectedValueが正確にnullとして返される可能性はありますか?

于 2010-05-13T17:23:27.523 に答える