Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex: Determine if a component is showing

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 show and hide events fire for visibility, and this seems to work for the first descendant of a ViewStack component, but not further down the display tree.

like image 323
Michael Brewer-Davis Avatar asked Jan 16 '09 22:01

Michael Brewer-Davis


1 Answers

... or avoiding recursion:

public static function isVisible(obj:DisplayObject):Boolean
{
    while (obj && obj.visible && obj !== Application.application)
    {
        obj = obj.parent;
    }
    return obj && obj.visible;
}
like image 83
KspR Avatar answered Oct 18 '22 20:10

KspR