Quick Tip: stage.mouseX on Android

When working with AIR on Android, I felt into an issue with stage.mouseX (stage.mouseY) returning value 107374182. It seems I am not the only one who experience that, but also Michael Ritchie and Lex Talkington did. This happens after you release touch screen. You may expect that Event.MOUSE_LEAVE would be fired in the right moment, but that sometimes just does not (sometime it does). I did not found any better solution than testing returned values against the static number, so I came up with this piece of code:

if(stage && (int(Math.abs(stage.mouseX)) == 107374182 
    || int(Math.abs(stage.mouseY)) == 107374182))

2 comments so far

  1. Tamas Gronas January 28, 2011 15:12


    I have now the same issue in my current project, but the number what I get is different from yours. My mouseY is 89481878.8. Is it maybe depends on devices?
    Anyway I solved this problem in the following way:
    if the mouseX or mouseY is greater than the width or height of the current display object when I check mouse coordinates on, set the correct values.

    I hope it will be useful.



  2. Jozef Chúťka January 31, 2011 12:18

    Hi Tamas,
    now it sounds like device specific issue, thank you for a feedback. You have made a nice solution indeed. I think I would recommend to transform local mouseX, mouseY values to global ones, and test against flash stageWidth, stageHeight and 0, 0 also.
    … + maybe considering some offset to these values because when you use the same flash on a desktop you can drag mouse outside the flash box and the valid values goes to negative or higher than stage size.

Leave a comment

Please be polite and on topic. Your e-mail will never be published.