4 Replies Latest reply on Aug 30, 2009 12:55 PM by darren.y.ng

    Determine if InteractiveObject is clipped/hidden




      I have an algorithm for triggering MouseEvent.CLICK from any random visible and enabled sprites on my stage to cheaply simulate user interactions with my application.


      I'm interested in determining if an InteractiveObject is clipped by its parent sprite or if it is "covered" by another sprite in the display list. For example, I have a set of buttons on the screen but cover them with a splash screen.


      I'm lazy and the buttons are still enabled and visible when they're covered. I can't actually interact with them though because the splash screen doesn't let events through. Is there an easy way (ie. single function call) to find out that the buttons are not actually usable? Or is there a way (doesn't have to be  easy) to figure out that the buttons are clipped/hidden by the splash screen?


      Thanks in advance,



        • 1. Re: Determine if InteractiveObject is clipped/hidden
          Barna Biro Level 3

          I'm guessing that the Splash Screen is not always visible. So you should know when it's removed... When that happens, simply enable the buttons. An even better approach would have been: not to add the buttons and who knows what under the Splash Screen... I don't understand why did you do something like this but I can surely say that it's senseless and as you found out yourself, it only leads to trouble.


          Another solution would be a hit test, check if a Slash Screen is hitting any of the buttons. But honestly, I think you're overcomplicating this, you shouldn't have added any buttons or elements before the Splash Screen is gone. Only once the user navigated away from the Splash Screen should have you added the new elements.

          • 2. Re: Determine if InteractiveObject is clipped/hidden
            darren.y.ng Level 1

            Two response to that:

            Yes, it's a pretty goofy set up. In my contrived example, it's simple to disable the small number of objects on the screen. In reality though, I could have hundreds of interactive objects, all in various states at any given moment. I could write a whole lot of code to keep track of button states, or I could cover it all up with a single object that will prevent touches from getting through. But I understand your point and it makes a lot of sense.


            The more significant problem with your solution though is that my splash screen is used to cover up applications built by 3rd parties. I can't guarantee their buttons and other interactive objects are disabled when I want to show my splash screen. The 3rd party doesn't necessarily know when the splash screen is coming up. So my algorithm to randomly touch objects ends up scanning their active buttons even though they can't technically be touched.


            Again, your point is valid in that I could potentially just go through the entire sprite display list and forcibly disable everything. However, it's probably not in my best interest to do so, because the thing I'm covering up is a 3rd party application and I could potentially screw up their application's states.


            In any case, thanks for the quick response. I'm looking forward to hearing more opinions...

            • 3. Re: Determine if InteractiveObject is clipped/hidden
              Barna Biro Level 3

              I'm not really getting the 3rd party part. I'm guessing that these "3rd party objects" are in fact separate .swf files that are somewhat loaded into your application that has a splash screen ( otherwise, I really can't image how the whole thing would look like ). If this is the case, then since you always know when a 3rd party .swf file displayed you just need to delay it... What I mean by this: I'm guessing that you are preloading both the splash screen and the 3rd party .swf at the same time and adding both to the display list at the same time... well, what if you just add the splash screen, and add the 3rd party .swf after the user navigates away from the splash screen? ( the .swf would already be preloaded and ready to display ).


              If I didn't understand then problem right, then a link or a few screen shots would surely help.

              • 4. Re: Determine if InteractiveObject is clipped/hidden
                darren.y.ng Level 1

                First off, I want to thank you for your time. It's very appreciated.


                I've attached a simple diagram of two potential states in my application. The first state is the base state. The blue area is my application. The green area is a 3rd party application, which is a separate SWF as you've correctly deduced, with its own interactive elements. The green area is contained in the blue area... ie. I've loaded it and added it as a child of my application. As an example, I have a help button in my application. The second state represents when the help button has been pressed and the purple "splash screen" comes up on top of the 3rd party application. The help screen may or may not have additional interactive elements.


                So, to get back to my original problem, I have an in-house test tool that simulates user interactions by searching through the display list for enabled interactive objects. I have no control over whether or not this 3rd party application enables or disables their buttons when I press the help button, but I know that my help screen effectively prevents touches from getting to those 3rd party interactive objects. When my test tool is running, I'd like to be able to determine if a particular sprite (one of the green interactive objects in my example) is covered/clipped so that I know if I can safely ignore it during my test tool's search. Is there such a function in any of the Flex/Flash libraries?