【问题标题】:AS3: How to know if a textField is DynamicAS3:如何知道 textField 是否是动态的
【发布时间】:2012-09-05 18:30:55
【问题描述】:

是否有可能知道显示对象内的文本字段是否是动态的? 我正在循环显示对象的所有子项,我只想找到动态文本字段(我也输入了 tf,我想避免它们) 谢了

【问题讨论】:

    标签: actionscript-3 flash textfield


    【解决方案1】:

    使用type属性,会返回一个字符串TextFieldType枚举值:

    //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

    【讨论】:

    • 谢谢,真丢脸,我错过了文档的 type 属性:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-01
    • 2013-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多