3 Replies Latest reply on May 8, 2011 7:12 AM by adxba

    Flash in Director with Touchscreen

    BSpero Level 1
      Hey all,
      So, I have run into a problem here that an exhaustive search of the web has turned up few answers for. I have a number of Flash sprites within my Director movie, and need them to respond to mouse clicks. On a touchscreen, it seems Flash will only detect the click after the mouse has been positioned over the sprite. So, you have to touch it twice in order to activate it. I know I'll get some suggestions about making the event on the "onRelease" but this does not help. Also, I can't set the touchscreen to detect a click and release when the person touches the screen because I have things that need to be dragged around. I know that there must be some solution, but so far I have had no luck. I have tried to set the mouse location as soon as the mouseDown is sent to the movie, but even then, the sprite needs a second click to detect it. Operating with the mouse works just fine, as one click will do it... A couple other folks who have had this problem, and maybe articulated it better...

      http://director-online.com/forums/read.php?1,20690,20710

      http://www.directorforum.de/showthread.php?t=52818

      http://www.directorforum.de/showthread.php?t=54055

      I am pretty good at figuring stuff out, but this really has me stumped. Just looking for more ideas...
        • 1. Re: Flash in Director with Touchscreen
          DAVID NAJAR Level 1
          Hi,

          I’ve made some apps for touch screen systems and I’ve never have any problem, then I’ll try to help but exist the case I’m complete wrong!!!

          First, if you want to fire a mouseDown or any other Director handler in a behavior attached to a sprite just call it like any other user defined handler. For example you have a sprite on channel 1 with the on mouseDown handler and you want to fire that without any mouse click or other mouse method, just put on the message window or on a timeout object or any where you like this: sprite(1).mouseDown()

          Ok it was simple but for flash sprites it couldn’t be so different just write the function on Flash and then call it, example: if sprite 1 is a flash asset with a function defined on Flash’s IDE named doSomeThing() then write on Director: sprite(1).doSomeThing()

          Ok we keep it on simple, just go on: if you want fire some fixed flash event like “click”, “change” or any other Flash fixed event (like Flash components events) just attach to the Director´s Flash sprite a behavior with the flash function translated to director handler and activate that event on the property inspector like this:

          on click
          put “a click happened”
          end

          or

          on change
          put “some change”
          end

          You can call it even with no occurrence of that event, fire it wherever you want: sprite(1).click() or sprite(1).change()

          If I remember well there was a problem with the Flash 8 assets events, simply doesn’t work but on recent Director’s updates it was fixed (I think). Just in case I put the code needed with that issue:

          property pFlashButton

          on beginSprite me
          pFlashButton = sprite(me.spriteNum)
          vFlashButtonEvent = pFlashButton .newObject("Object")
          pFlashButton .setCallback(vFlashButtonEvent, "click", 0, 0)
          end

          or

          property pFlashDataGrid

          on beginSprite me
          pFlashDataGrid = sprite(me.spriteNum)
          vFlashDataGridEvent = pFlashDataGrid.newObject("Object")
          pFlashDataGrid.setCallback(vFlashDataGridEvent , "change", 0, 0)
          end


          This will detect those events and call your own on click or on change handlers on the same behavior

          Then the last thing, how to know which sprite function fire with the touch of the screen if no mouse enter occurred first? Well you can use the_mouse.clickOn on a movie script mouseDown event or in the mouseDownScript to know which sprite was clicked and then call the sprite functions or handlers, just remember that the _mouse.clickOn property works only with active sprites (sprites with scripts attached on. You can attach a dummy behavior to do nothing in case no behavior present on the sprite)

          There’re more solutions but they are more complex and could impact your application’s code design.

          Really I hope this can help.

          Have a nice coding!!!
          • 2. Touchscreen apps
            Jazzybossa

            Hi, i was interested in your comments. I've made a mouse controlled flipbook in inDesign and I'd like to make it a touchscreen book so the page turns, narration and video content can be activated by touch. Is it possible? It should be easy to bring the inDesign into Flash pro.  

            • 3. Re: Flash in Director with Touchscreen
              adxba

              Hi,

               

              Had exactly the same issue  a few years ago! Seems certain touch screens with certain settings have this issue (It didn't seem to happen with every touch screen!). From what i can gather it is as if the mouse focus is torn between the director file and the embedded flash file. So the first click is setting the focus to the flash file, the second is then working!

               

              Anyway I'll save you the months of searching with this workaround that works for me!

              Make sure the scrips below are moviescripts.

               

              on prepareMovie

                the mouseDownScript = "fixFlash" --Flash button focus fix

              end

               


              on fixFlash

                updateStage()

              end

               

               

              Hope this help you!

               

              Tim