Flex: Determine if a component is showing

后端 未结 6 1428
太阳男子
太阳男子 2021-02-20 02:42

What is the best way to determine if a component in Flex/Flash is showing on the user\'s screen? I\'m looking for an analog to Java\'s Component.isShowing() method.

The

6条回答
  •  终归单人心
    2021-02-20 03:05

    This is all you really need. The "Application.application" check is futile.

            /**
             * Returns `true` if this component is actually shown on screen currently. This could be false even with
             * "visible" set to `true`, because one or more parents could have "visible" set to `false`.
             */
            public static function isShowing (c : DisplayObject) : Boolean {
                while (c && c.visible && c.parent) {
                    c = c.parent;
                }
                return c.visible;
            }
    

提交回复
热议问题