Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Developer
bba
Posts: 266
Registered: ‎04-01-2009
My Device: Not Specified

Detect a TouchEvent

Hello,

I would like to detect a TouchEvent when the user touches the screen and drags his finger along.

Which TouchEvent do I use then?

 

Thanks guys!

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Detect a TouchEvent

hey bba,

 

you can do touch events like this following article with a tutorial:

 

http://www.adobe.com/devnet/flash/articles/multitouch_gestures.html

 

however at the current moment touch events cannot be tested on the simulator. you should only use the MouseEvent class instead since it is able to be tested without the device. they are equivelant to single touch point events and use less over head. here is more information on that class:

 

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/MouseEvent.html

 

hope that helps. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
Developer
bba
Posts: 266
Registered: ‎04-01-2009
My Device: Not Specified

Re: Detect a TouchEvent

Thanks! looks like the TouchEvent.TOUCH_MOVE is the one where the user drags the finger over the screen. Is there something like this in MouseEvent?

How else can I get an event to get the x and y position of the current point when the user drags the finger?

Please use plain text.
Developer
Brandon_Appetizer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook
My Carrier: WiFi

Re: Detect a TouchEvent

The event you are looking for is MouseEvent.MOUSE_MOVE. Combine this with a MouseEvent.MOUSE_DOWN to catch when they start clicking (put a finger down) and MouseEvent.MOUSE_UP to catch when they release (lift finger).

 

For example:

 

 

this.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down_event);
this.addEventListener(MouseEvent.MOUSE_MOVE, mouse_move_event);
this.addEventListener(MouseEvent.MOUSE_UP, mouse_up_event);

private function mouse_down_event(event:MouseEvent):void
{
 // Finger pressed, store X, Y, other info you need
}

private function mouse_move_event(event:MouseEvent):void
{
 // Mouse moved, make changes based on the new X, Y, or other info
}

private function mouse_up_event(event:MouseEvent):void
{
 // Finger lifted, stop dragging or whatever the user was doing
}

 

 

Check the following for reference on MouseEvents:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/MouseEvent.html

 

You would probably be interested in using event.stageX and event.stageY. You could also not bother tracking the MOUSE_DOWN and MOUSE_UP events and just check if event.buttonDown is true on the MOUSE_MOVE event, depending on your use case.

 

 

----------------------------------------
If this post solved your problem, please click the 'Accept as Solution' button.
If you found this post useful, please provide a Kudo. Thanks.

Approved Apps: Celestial Slingshot
Please use plain text.