开发者

Set Style and Disable Focus for ALL AS3 TextInput Components?

How to "开发者_如何学PythonsetStyle" and "disable focus" (remove the default blue line rectangle when focus) for "ALL" AS3 TextInput components?


Unless you plan to somehow keep a record of them, I think the best way would probably be to recurse the display list looking for instances of that class. Something like:

// Necessary imports
import flash.display.DisplayObjectContainer;
import flash.display.DisplayObject;
import fl.controls.TextInput;


function disableAllInputs(container : DisplayObjectContainer) : void
{
    var i : uint;
    for (i=0; i<container.numChildren; i++) {
        var child : DisplayObject = container.getChildAt(i);
        if (child is TextInput) {                       // Proper class here
           var input : TextInput = TextInput(child);    // and here
           // Disable focus and setStyle here
        }
        else if (child is DisplayObjectContainer) {
           // Recurse
           disableAllInputs(child as DisplayObjectContainer);
        }
    }
}

This will loop through all the children of the supplied container and check if they are inputs. If they are, you can execute the desired code for them in the appropriate if statement. If however they are other containers, it will recurse and loop through the children of that container too.

I'm not sure what the class name is of the text input component, but I think it's simply TextInput. If not, just replace with the proper name where marked in the above source code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜