| パッケージ | fl.controls |
| クラス | public class RadioButtonGroup |
| 継承 | RadioButtonGroup EventDispatcher Object |
| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
関連する API エレメント
| プロパティ | 定義元 | ||
|---|---|---|---|
![]() | constructor : Object
指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクター関数への参照です。 | Object | |
| name : String [読み取り専用]
ラジオボタンのインスタンス名を取得します。 | RadioButtonGroup | ||
| numRadioButtons : int [読み取り専用]
このラジオボタングループ内のラジオボタンの数を取得します。 | RadioButtonGroup | ||
| selectedData : Object
選択されているラジオボタンの value プロパティを取得または設定します。 | RadioButtonGroup | ||
| selection : RadioButton
ラジオボタングループの現在選択されているラジオボタンを指す参照を取得または設定します。 | RadioButtonGroup | ||
| メソッド | 定義元 | ||
|---|---|---|---|
RadioButtonGroup(name:String)
新しい RadioButtonGroup インスタンスを作成します。 | RadioButtonGroup | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
イベントリスナーオブジェクトを EventDispatcher オブジェクトに登録し、リスナーがイベントの通知を受け取るようにします。 | EventDispatcher | |
ラジオボタングループインデックス用に使用するラジオボタンを内部ラジオボタン配列に追加し、ラジオボタンのグループから 1 つのラジオボタンを選択できるようにします。 | RadioButtonGroup | ||
![]() |
イベントをイベントフローに送出します。 | EventDispatcher | |
[静的]
指定されたラジオボタングループへの参照を取得します。 | RadioButtonGroup | ||
指定されたインデックス位置にある RadioButton コンポーネントを取得します。 | RadioButtonGroup | ||
指定された RadioButton インスタンスのインデックスを返します。 | RadioButtonGroup | ||
![]() |
EventDispatcher オブジェクトに、特定のイベントタイプに対して登録されたリスナーがあるかどうかを確認します。 | EventDispatcher | |
![]() |
オブジェクトに指定されたプロパティが定義されているかどうかを示します。 | Object | |
![]() |
Object クラスのインスタンスが、パラメーターとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。 | Object | |
![]() |
指定されたプロパティが存在し、列挙できるかどうかを示します。 | Object | |
![]() |
EventDispatcher オブジェクトからリスナーを削除します。 | EventDispatcher | |
RadioButton インスタンスをラジオボタンの内部リストからクリアします。 | RadioButtonGroup | ||
![]() |
ループ処理に対するダイナミックプロパティの可用性を設定します。 | Object | |
![]() |
ロケール固有の規則に従って書式設定された、このオブジェクトのストリング表現を返します。 | Object | |
![]() |
指定されたオブジェクトのストリング表現を返します。 | Object | |
![]() |
指定されたオブジェクトのプリミティブな値を返します。 | Object | |
![]() |
指定されたイベントタイプについて、この EventDispatcher オブジェクトまたはその祖先にイベントリスナーが登録されているかどうかを確認します。 | EventDispatcher | |
| イベント | 概要 | 定義元 | ||
|---|---|---|---|---|
![]() | [ブロードキャストイベント] Flash Player または AIR アプリケーションがオペレーティングシステムのフォーカスを取得して、アクティブになったときに送出されます。 | EventDispatcher | ||
| グループ内の選択した RadioButton インスタンスが変更されたときに送出されます。 | RadioButtonGroup | |||
| RadioButton インスタンスがクリックされたときに送出されます。 | RadioButtonGroup | |||
![]() | [ブロードキャストイベント] Flash Player または AIR アプリケーションがオペレーティングシステムのフォーカスを失って、非アクティブになったときに送出されます。 | EventDispatcher | ||
name | プロパティ |
numRadioButtons | プロパティ |
selectedData | プロパティ |
selectedData:Object| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
選択されているラジオボタンの value プロパティを取得または設定します。現在ラジオボタンが選択されていない場合、このプロパティは、 null です。
実装
public function get selectedData():Object public function set selectedData(value:Object):void例 ( この例の使用方法 )
change イベントをリッスンします。
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
var myRadioGroup:RadioButtonGroup = new RadioButtonGroup("options");
myRadioGroup.addEventListener(Event.CHANGE, changeHandler);
var radio1:RadioButton = new RadioButton();
radio1.label = "Option A";
radio1.value = "optionA";
radio1.group = myRadioGroup;
radio1.move(10, 10);
addChild(radio1);
var radio2:RadioButton = new RadioButton();
radio2.label = "Option B";
radio2.value = "optionB";
radio2.group = myRadioGroup;
radio2.move(10, 30);
addChild(radio2);
var radio3:RadioButton = new RadioButton();
radio3.label = "Option C";
radio3.value = "optionC";
radio3.group = myRadioGroup;
radio3.move(10, 50);
addChild(radio3);
function changeHandler(event:Event):void {
var rbg:RadioButtonGroup = event.target as RadioButtonGroup;
if (rbg.selectedData != null) {
trace(rbg.selectedData);
} else {
trace("no value specified.");
}
}
selection | プロパティ |
selection:RadioButton| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
ラジオボタングループの現在選択されているラジオボタンを指す参照を取得または設定します。
実装
public function get selection():RadioButton public function set selection(value:RadioButton):void例 ( この例の使用方法 )
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
var radioGroup:RadioButtonGroup = new RadioButtonGroup("rbg");
radioGroup.addEventListener(Event.CHANGE, changeHandler);
var radio1:RadioButton = new RadioButton();
radio1.group = radioGroup;
radio1.label = "Option A";
radio1.value = 1;
radio1.move(10, 10);
addChild(radio1);
var radio2:RadioButton = new RadioButton();
radio2.group = radioGroup;
radio2.label = "Option B";
radio2.value = 2;
radio2.move(10, 30);
addChild(radio2);
function changeHandler(event:Event):void {
var rg:RadioButtonGroup = event.currentTarget as RadioButtonGroup;
trace("change:", rg.selection.label, "(" + rg.selectedData + ")");
}
RadioButtonGroup | () | コンストラクター |
addRadioButton | () | メソッド |
public function addRadioButton(radioButton:RadioButton):void| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
ラジオボタングループインデックス用に使用するラジオボタンを内部ラジオボタン配列に追加し、ラジオボタンのグループから 1 つのラジオボタンを選択できるようにします。このメソッドはラジオボタンによって自動的に使用されますが、手動で使用してグループにラジオボタンを明示的に追加することもできます。
パラメーター
radioButton:RadioButton — 現在のラジオボタングループに追加する RadioButton インスタンスです。
|
getGroup | () | メソッド |
public static function getGroup(name:String):RadioButtonGroup| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
指定されたラジオボタングループへの参照を取得します。
パラメーター
name:String — 参照を取得するグループの名前。
|
RadioButtonGroup — 指定した RadioButtonGroup への参照。
|
例 ( この例の使用方法 )
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
var rbg1:RadioButtonGroup = new RadioButtonGroup("group1");
var rb1:RadioButton = new RadioButton();
rb1.label = "Choice A";
rb1.group = rbg1;
rb1.move(10, 10);
rb1.addEventListener(MouseEvent.CLICK, announceCurrentGroup);
addChild(rb1);
var rb2:RadioButton = new RadioButton();
rb2.label = "Choice B";
rb2.group = rbg1;
rb2.move(10, 30);
rb2.addEventListener(MouseEvent.CLICK, announceCurrentGroup);
addChild(rb2);
function announceCurrentGroup(e:MouseEvent):void {
var group:RadioButtonGroup = RadioButtonGroup.getGroup("group1");
trace("The currently selected radio button is: " + group.selection.label);
}
getRadioButtonAt | () | メソッド |
public function getRadioButtonAt(index:int):RadioButton| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
指定されたインデックス位置にある RadioButton コンポーネントを取得します。
パラメーター
index:int — RadioButtonGroup コンポーネント内の RadioButton コンポーネントのインデックス。最初のコンポーネントのインデックスは 0 です。
|
RadioButton — 指定された RadioButton コンポーネント。
|
例外
RangeError — 指定したインデックス位置は 0 未満か、またはデータプロバイダーの長さ以上です。
|
getRadioButtonIndex | () | メソッド |
public function getRadioButtonIndex(radioButton:RadioButton):int| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
指定された RadioButton インスタンスのインデックスを返します。
パラメーター
radioButton:RadioButton — 現在の RadioButtonGroup 内で検索する RadioButton インスタンスです。
|
int — 指定した RadioButton コンポーネントのインデックスか、指定した RadioButton が見つからなかった場合は -1。
|
removeRadioButton | () | メソッド |
public function removeRadioButton(radioButton:RadioButton):void| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
RadioButton インスタンスをラジオボタンの内部リストからクリアします。
パラメーター
radioButton:RadioButton — 削除する RadioButton インスタンスです。
|
change | イベント |
flash.events.Eventプロパティ Event.type =
flash.events.Event.CHANGE| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
グループ内の選択した RadioButton インスタンスが変更されたときに送出されます。
Event.CHANGE 定数は、type プロパティ(change イベントオブジェクト)の値を定義します。
このイベントには、次のプロパティがあります。
| プロパティ | 値 |
|---|---|
bubbles | true |
cancelable | false は、キャンセルするデフォルトの動作がないことを示します。 |
currentTarget | イベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。 |
target | 値が変更されたオブジェクトです。target は、必ずしもイベントリスナーを登録した表示リスト内のオブジェクトとは限りません。現在イベントを処理している表示リスト内のオブジェクトにアクセスするには、currentTarget プロパティを使用します。 |
例 ( この例の使用方法 )
change イベントのイベントリスナーを追加します。
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
var myRadioGroup:RadioButtonGroup = new RadioButtonGroup("options");
myRadioGroup.addEventListener(Event.CHANGE, changeHandler);
var radio1:RadioButton = new RadioButton();
radio1.label = "Option A";
radio1.group = myRadioGroup;
radio1.move(10, 10);
addChild(radio1);
var radio2:RadioButton = new RadioButton();
radio2.label = "Option B";
radio2.group = myRadioGroup;
radio2.move(10, 30);
addChild(radio2);
var radio3:RadioButton = new RadioButton();
radio3.label = "Option C";
radio3.group = myRadioGroup;
radio3.move(10, 50);
addChild(radio3);
function changeHandler(event:Event):void {
var rg:RadioButtonGroup = event.target as RadioButtonGroup;
switch (rg.selection) {
case radio1:
trace("radio1");
break;
case radio2:
trace("radio2");
break;
case radio3:
trace("radio3");
break;
}
}
click | イベント |
flash.events.MouseEventプロパティ MouseEvent.type =
flash.events.MouseEvent.CLICK| 言語バージョン: | ActionScript 3.0 |
| 製品バージョン: | Flash CS3 |
| ランタイムバージョン: | Flash Player 9.0.28.0, AIR 1.0 |
RadioButton インスタンスがクリックされたときに送出されます。
type プロパティ(click イベントオブジェクト)の値を定義します。
このイベントには、次のプロパティがあります。
| プロパティ | 値 |
|---|---|
altKey | Alt キーがアクティブになっている場合は true(Windows) |
bubbles | true |
buttonDown | クリックイベントでは、この値は常に false となります。 |
cancelable | false は、キャンセルするデフォルトの動作がないことを示します。 |
commandKey | Macintosh で Command キーがアクティブになっている場合は true、非アクティブになっている場合は false です。 Windows では常に false になります。 |
controlKey | Ctrl キーまたは Control キーがアクティブになっている場合は true、非アクティブになっている場合は false です。 |
ctrlKey | Windows または Linux では Ctrl キーがアクティブになっている場合は、true です。Macintosh では Ctrl キーまたは Command キーがアクティブになっている場合は、true です。それ以外の場合は false です。 |
currentTarget | イベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。 |
localX | マウスロックが無効になっているときにイベントが発生する位置の、スプライトを基準とする水平座標です。 |
localY | マウスロックが無効になっているときにイベントが発生する位置の、スプライトを基準とする垂直座標です。 |
movementX | マウスロックが有効になっているときに、マウス位置の水平座標について、前回のマウスイベント時点からの移動量を示します。 |
movementY | マウスロックが有効になっているときに、マウス位置の垂直座標について、前回のマウスイベント時点からの移動量を示します。 |
shiftKey | Shift キーがアクティブになっている場合は true、非アクティブになっている場合は false です。 |
stageX | グローバルステージ座標を基準とするイベント発生位置の水平座標です。 |
stageY | グローバルステージ座標を基準とするイベント発生位置の垂直座標です。 |
target | ポインティングデバイスの下にある InteractiveObject インスタンスです。target は、必ずしもイベントリスナーを登録した表示リスト内のオブジェクトとは限りません。現在イベントを処理している表示リスト内のオブジェクトにアクセスするには、currentTarget プロパティを使用します。 |
- ライブラリに RadioButton および Label コンポーネントを追加します。
- このコードを FLA と同じディレクトリに RadioButtonGroupExample.as という名前で保存します。
- FLA 内の DocumentClass を RadioButtonGroupExample に設定します。
package
{
import flash.text.TextFieldAutoSize;
import flash.display.Sprite;
import flash.events.Event;
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
import fl.controls.Label;
public class RadioButtonGroupExample extends Sprite
{
private var padding:uint = 10;
private var currHeight:uint = 0;
private var verticalSpacing:uint = 30;
private var posX:uint;
private var reportLabel:Label;
public function RadioButtonGroupExample() {
setupRadioButtons();
}
private function setupRadioButtons():void {
reportLabel = new Label();
reportLabel.move(10,150);
reportLabel.autoSize = TextFieldAutoSize.LEFT;
reportLabel.text = "Select a Radio Button";
addChild(reportLabel);
createRadioButtonGroup("1st Group");
createRadioButtonGroup("2nd Group");
createRadioButtonGroup("3rd Group");
createRadioButtonGroup("4th Group");
}
private function createRadioButtonGroup(name:String):void {
var rbg:RadioButtonGroup = new RadioButtonGroup(name);
rbg.addEventListener(Event.CHANGE, announceChange);
createRadioButton("1st Button", rbg, posX);
createRadioButton("2nd Button", rbg, posX);
createRadioButton("3rd Button", rbg, posX);
createRadioButton("4th Button", rbg, posX);
posX += 125;
currHeight = 0;
}
private function createRadioButton(rbLabel:String,rbg:RadioButtonGroup,posX:uint):void {
var rb:RadioButton = new RadioButton();
rb.group = rbg;
rb.label = rbLabel;
rb.move(posX, padding + currHeight);
addChild(rb);
currHeight += verticalSpacing;
}
private function announceChange(e:Event):void {
var rbg:RadioButtonGroup = e.target as RadioButtonGroup;
var rb:RadioButton = rbg.selection;
reportLabel.text = rbg.name + " has selected " + rb.label;
}
}
}
Tue Jun 12 2018, 10:34 AM Z
継承されるパブリックプロパティを隠す
継承されるパブリックプロパティを表示