1

表示オブジェクト内の textField が動的かどうかを知ることは可能ですか? 表示オブジェクトのすべての子をループしており、動的テキスト フィールドのみを検索したい (tf も入力したので、それらを避けたい) THX

4

1 に答える 1

3

文字列 TextFieldType 列挙値を返す type プロパティを使用します。

//Assuming a DisplayObjectContainer called 'doc':
for (var i:int = 0; i < doc.numChildren; i++) 
{
    var tf:TextField = doc.getChildAt(i) as TextField;
    if (tf != null) // Will be null if the child isn't a TextField
    {
        switch(tf.type)
        {
            case TextFieldType.DYNAMIC:
                trace("Dynamic");
                break;
            case TextFieldType.INPUT:
                trace("Input");
                break;
        }
    }
}

ドキュメントは素晴らしく明確です:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#type

于 2012-09-05T18:34:04.007 に答える