Flash Lite 2.x および 3.0 ヘルプ

onSetFocus (Selection.onSetFocus イベントリスナー)

onSetFocus = function([oldfocus], [newfocus]) {}

フォーカスが変更されると、通知されます。このリスナーを使用するには、リスナーオブジェクトを作成します。次にこのリスナーの関数を定義し、Selection.addListener() メソッドを使用してリスナーを Selection オブジェクトに登録します。次に例を示します。

var someListener:Object = new Object();
someListener.onSetFocus = function () {
    // ステートメント
}
Selection.addListener(someListener);

1 つのイベントに関する通知を複数のリスナーで受け取ることができるので、リスナーごとに異なる複数のコードを作成して連携させることもできます。

パラメータ

oldfocus: (オプション) - フォーカスを失うオブジェクト。

newfocus: (オプション) - フォーカスを受け取るオブジェクト。

次の例では、ダイナミックに作成された複数のテキストフィールドの間で、SWF ファイルの入力フォーカスの移動のタイミングを判断する方法について説明します。次の ActionScript を FLA または AS ファイルに入力し、ドキュメントをテストします。

this.createTextField("one_txt", 1, 0, 0, 100, 22);
this.createTextField("two_txt", 2, 0, 25, 100, 22);
this.createTextField("three_txt", 3, 0, 50, 100, 22);
this.createTextField("four_txt", 4, 0, 75, 100, 22);

for (var i in this) {
    if (this[i] instanceof TextField) {
    this[i].border = true;
    this[i].type = "input";
    }
}

this.createTextField("status_txt", this.getNextHighestDepth(), 200, 10, 300, 100); 
status_txt.html = true;
status_txt.multiline = true;

var someListener:Object = new Object();
someListener.onSetFocus = function(oldFocus, newFocus) {
    status_txt.htmlText = "<b>setFocus triggered</b>";
    status_txt.htmlText += "<textformat tabStops='[20,80]'>";
    status_txt.htmlText += "&nbsp;¥toldFocus:¥t"+oldFocus;
    status_txt.htmlText += "&nbsp;¥tnewFocus:¥t"+newFocus;
    status_txt.htmlText += "&nbsp;¥tgetFocus:¥t"+Selection.getFocus();
    status_txt.htmlText += "</textformat>";
};
Selection.addListener(someListener);

関連項目

addListener (Selection.addListener メソッド), setFocus (Selection.setFocus メソッド)

 

このページに新しいコメントが追加された場合に、電子メールでの通知を希望する。 | コメントレポート