4 Replies Latest reply on Apr 9, 2010 5:13 AM by Carl Woffenden

    Passing mouse/key events to linked movies?

    Carl Woffenden Level 1

      Hi! Does anyone know how events can be passed to linked movies? For example, I have a self contained menu movie as a linked member of my main movie, but when placed on the stage the linked movie doesn't receive mouse or key events. Running the menu movie standalone works fine. Calling functions of the menu movie from the main movie is also no problem, e.g.: sprite(n).movie.myFunction(). I started using the technique to bundle together self contained functionality but seem to have run into wall where the events are concerned (with the only workaround so far to be to pass the mouse calls from the linked movie's sprite and do a linear search on the sprite bounds to find what was clicked). This is in Director 11.5 (but the problem exists going as far back as version 7).

       

      This video demonstrates better what I mean:

       

          http://digicont.ch/aland/aland-170210.mov

       

      Ignore for a moment that Director is playing back on J2ME, that's a whole other post!

       

      Regards,

       

      Carl

        • 2. Re: Passing mouse/key events to linked movies?
          Carl Woffenden Level 1

          Thanks for the link, I'd not looked at the Wiki there before. I looked further into my problem and narrowed it down to: events aren't passed to the LDM if the parent movie has a behavior on the LDM's sprite. Here's a simple example:

           

              http://www.numfum.com/cw/ldm-090410.zip

           

          It contains two (D11) dirs, 'test12b' is the LDM, 'test12a' is the parent movie. Open 'test12a'; on the left the LDM sprite has no behaviors, on the right it does. Click on the left pink or black dudes and the message window should show which was clicked (and passes the event to the LDM's frame script), try the same on the right but the events never get passed on (the pass() only goes to the parent frame script).

           

          Carl

          • 3. Re: Passing mouse/key events to linked movies?
            Mike Blaustein Level 4

            You have come to the right conclusion.  If there is a behaviour on the LDM sprite, any event is absorbed by it and not passed on.  You need to manually deal with them... tedious and messy, but it should work:

             

            --in the parent movie, #behavior on the LDM sprite:

             

            on mouseWithin me

                 sprite(me.spriteNum).movie.sendAllSprites(#mouseLocation,the mouseLoc)

            end

             

            on mouseUp me

                 sprite(me.spriteNum).movie.sendAllSprites(#mouseEventUp,the mouseLoc)

            end

             

            --in the LDM movie, #behavior on every sprite that needs these events

            on mouseLocation me, vMouseLoc

                 if vMouseLoc.inside(sprite(me.spriteNum).rect) then

                      --do whatever needs doing

                 end if

            end

             

            on mouseEventUp me, vMouseLoc

                 if vMouseLoc.inside(sprite(me.spriteNum).rect) then

                      me.mouseUp()

                 end if

            end

             

            on mouseUp me

                 --do something

            end

            • 4. Re: Passing mouse/key events to linked movies?
              Carl Woffenden Level 1

              Thanks for your help. I'd been doing something similar (passing the mouse event to the LDM's movie script, then searching through its sprite rects before doing a sendSprite on the matching one). I think the better solution is simply not to put scripts on the parent movie's LDM sprite and let the LDM itself be self contained, passing messages back to the parent if required. It means not having frame events (which never get triggered) but at least they can be simulated with passing sprite events onto the frame.

               

              Carl