I am developing an iOS game in Flash CS6.
I have a basic movement test that I put in an Event.MOUSE_DOWN handler.
What I’m expecting/wanting is when I held my finger down on the button, that the player would keep moving until I stop touching the screen.
What happens though, is I have to keep constantly tapping to keep the player moving – rather than just hold my finger on the button and the player keeps moving.
What code should I use to accomplish what I want?
To accomplish this, you’ll need to run a function continuously in between
MouseEvent.MOUSE_DOWNandEvent.MOUSE_UPas MouseEvent.MOUSE_DOWN will only get dispatched one time per press.Here is a simple script to do just that:
As an aside, you may want to use the TOUCH events, as it gives more flexibility with multi-touch control. Though if you’re only ever going to allow one item to be pressed at any given time, it’s not an issue.
TO do that, just add
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINTin your document class, then replace your MouseEvent listeners with the appropriate touch event:MouseEvent.MOUSE_DOWNbecomes:TouchEvent.TOUCH_BEGINMouseEvent.MOUSE_UPbecomes:TouchEvent.TOUCH_END