A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Stacked objects that both interact with the mouse

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    8

    Stacked objects that both interact with the mouse

    Hi,
    I have an external SWF that I load into a Loader object.
    I add this Loader object as a child to a MovieClip and add this MovieClip to my stage.
    I now want to draw a transparent rectangular Sprite on top of the Loader object, that is just needed to catch mouse event.
    (I need to know when the mouse rolled over and rolled out of the transparent layer).

    If you're asking yourself - why do I need this transparent layer and not just catch the events on the Loader itself ?
    well, there are a lot of reasons for this, most of them have to do with the client requests, but also - because some externally loaded SWFs
    don't respond to the mouse events for some reason - so I need to 'trick' it and add my own transparent layer on top.


    My problem is - if I put the transparent layer as a child of the MovieClip that holds the Loader, then I get this hirarchy:


    problem is - mouse events are caught by the top-most layer (the transparent-layer) and passed on to the MovieClip and the Stage.
    The events aren't fired in the Loader object, and so - the SWF becomes non-interactive.


    The other solution would be - to somehow add the transparent layer as a child of the Loader object, like this:


    then the events would be bubbled up to the Loader and the SWF.
    Problem is - Loader class does not allow you to add child elements to it (except for the loaded SWF).


    So can anyone offer advice how I can add a transparent layer on top of the SWF and still have mouse interaction with both the transparent layer and the SWF layer ?

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Pu this line event.stopPropagation (); in the transparent layer eventhandler function. That prevents events from bubbling.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center