There is often confustion by new adaptors of Starling about what Events to use to handle touch/clicks.
Unlike AIR’s native TOUCH_BEGIN, TOUCH_END events, Starling uses a single TOUCH event, the type of touch is then extracted in the event handler through the event (e) object.
See below.
private function onTouch(e:TouchEvent):void { var touch:Touch = e.getTouch(stage); if(touch) { if(touch.phase == TouchPhase.BEGAN) { //There was a touch (MouseDown) } else if(touch.phase == TouchPhase.ENDED) { //The Touch ended (MouseUp) } else if(touch.phase == TouchPhase.MOVED) { //dragging } } }
There reason its setup this way is to be able to easily handle multiple touch events simultaneously.
I will discuss the tracking of multi-touches in another post.
So simple and so great.
thank you very much.