{"id":28591,"date":"2013-06-27T14:29:40","date_gmt":"2013-06-27T08:59:40","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=28591"},"modified":"2024-04-12T14:16:11","modified_gmt":"2024-04-12T08:46:11","slug":"handling-clicks-and-touch-events","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/","title":{"rendered":"Handling clicks and touch events"},"content":{"rendered":"<p><a class=\"vsc\" href=\"http:\/\/www.vskills.in\/certification\/Certified Blackberry Apps Developer\"><span class=\"vsc-cn\" style=\"text-align: center;\"><span style=\"color: red;\">Certify and Increase Opportunity.<\/span><br \/>\n<span style=\"color: green;\">Be <\/span><br \/>\nGovt. Certified Blackberry Apps Developer<br \/>\n<\/span><\/a><\/p>\n<h1>Touch event handling<\/h1>\n<ol>\n<li><span style=\"line-height: 1.714285714; font-size: 1rem;\">Touch Event properties<\/span><\/li>\n<li><span style=\"line-height: 1.714285714; font-size: 1rem;\">Touch event phases<\/span><\/li>\n<li><span style=\"line-height: 1.714285714; font-size: 1rem;\">Touch Point ID<\/span><\/li>\n<\/ol>\n<div>\n<div>\n<p>Basic touch events are handled the same way you handle other events, like mouse events, in ActionScript. You can listen for a series of touch events defined by the event type constants in the\u00a0TouchEvent class.<\/p>\n<div>Note:\u00a0For multiple touch point input (such as touching a device with more than one finger), the first point of contact dispatches a mouse event and a touch event.<\/div>\n<\/div>\n<div><\/div>\n<div>To handle a basic touch event:<\/div>\n<div><\/div>\n<div>\n<ol>\n<li>Set your application to handle touch events by setting the<br \/>\n<samp>flash.ui.Multitouch.inputMode<\/samp>\u00a0property to<samp>MultitouchInputMode.TOUCH_POINT<\/samp>.<\/li>\n<li>Attach an event listener to an instance of a class that inherits properties from the InteractiveObject class, such as Sprite or TextField.<\/li>\n<li>Specify the type of touch event to handle.<\/li>\n<li>Call an event handler function to do something in response to the event.<\/li>\n<\/ol>\n<\/div>\n<p>For example, the following code displays a message when the square drawn on mySprite is tapped on a touch-enabled screen:<\/p>\n<pre>Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT; \r\n\r\nvar mySprite:Sprite = new Sprite(); \r\nvar myTextField:TextField = new TextField(); \r\n\r\nmySprite.graphics.beginFill(0x336699); \r\nmySprite.graphics.drawRect(0,0,40,40); \r\naddChild(mySprite); \r\n\r\nmySprite.addEventListener(TouchEvent.TOUCH_TAP, taphandler); \r\n\r\nfunction taphandler(evt:TouchEvent): void { \r\n    myTextField.text = \"I've been tapped\"; \r\n    myTextField.y = 50; \r\n    addChild(myTextField); \r\n}<\/pre>\n<\/div>\n<div id=\"WS1ca064e08d7aa9302a91d3521257b43eee0-8000\">\n<h2>Touch Event properties<\/h2>\n<div>\n<p>When an event occurs, an event object is created. The TouchEvent object contains information about the location and conditions of the touch event. You can use the properties of the event object to retrieve that information.<\/p>\n<p>For example, the following code creates a TouchEvent object\u00a0<var>evt<\/var>, and then displays the<\/p>\n<p><samp>stageX<\/samp>property of the event object (the x-coordinate of the point in the Stage space that the touch occurred) in the text field:<\/p>\n<pre>Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT; \r\n\r\nvar mySprite:Sprite = new Sprite(); \r\nvar myTextField:TextField = new TextField(); \r\n\r\nmySprite.graphics.beginFill(0x336699); \r\nmySprite.graphics.drawRect(0,0,40,40); \r\naddChild(mySprite); \r\n\r\nmySprite.addEventListener(TouchEvent.TOUCH_TAP, taphandler); \r\n\r\nfunction taphandler(evt:TouchEvent): void { \r\nmyTextField.text = evt.stageX.toString; \r\nmyTextField.y = 50; \r\naddChild(myTextField); \r\n}<\/pre>\n<div>See the\u00a0TouchEvent\u00a0class for the properties available through the event object.<\/div>\n<div>\n<p>Note:\u00a0Not all TouchEvent properties are supported in all runtime environments. For example, not all touch-enabled devices are capable or detecting the amount of pressure the user is applying to the touch screen. So, the<samp>TouchEvent.pressure<\/samp>\u00a0property is not supported on those devices. Try testing for specific property support to ensure your application works, and seeTroubleshooting\u00a0for more information.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"WS0e220c58f53d1f422332527f126778fc72f-8000\">\n<h2>Touch event phases<\/h2>\n<div>\n<p>Track touch events through various stages over and outside an InteractiveObject just as you do for mouse events. And, track touch events through the beginning, middle, and end of a touch interaction. The TouchEvent class provides values for handling<\/p>\n<p><samp>touchBegin<\/samp>,<\/p>\n<p><samp>touchMove<\/samp>, and<\/p>\n<p><samp>touchEnd<\/samp>events.<\/p>\n<p>For example, you could use<\/p>\n<p><samp>touchBegin<\/samp>,<\/p>\n<p><samp>touchMove<\/samp>, and<\/p>\n<p><samp>touchEnd<\/samp>events to give the user visual feedback as they touch and move a display object:<\/p>\n<pre>Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT; \r\nvar mySprite:Sprite = new Sprite(); \r\nmySprite.graphics.beginFill(0x336699); \r\nmySprite.graphics.drawRect(0,0,40,40); \r\naddChild(mySprite); \r\nvar myTextField:TextField = new TextField(); \r\nmyTextField.width = 200; \r\nmyTextField.height = 20; \r\naddChild(myTextField); \r\n\r\nmySprite.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin); \r\nstage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove); \r\nstage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd); \r\nfunction onTouchBegin(event:TouchEvent) { \r\n    myTextField.text = \"touch begin\" + event.touchPointID; \r\n} \r\nfunction onTouchMove(event:TouchEvent) { \r\n    myTextField.text = \"touch move\" + event.touchPointID; \r\n} \r\nfunction onTouchEnd(event:TouchEvent) { \r\n    myTextField.text = \"touch end\" + event.touchPointID; \r\n}<\/pre>\n<div class=\"apply\">\n<h3>Apply for Blackberry Apps Certification Now!!<\/h3>\n<p><a href=\"http:\/\/www.vskills.in\/certification\/Certified-Blackberry-Apps-Developer\">http:\/\/www.vskills.in\/certification\/Certified-Blackberry-Apps-Developer<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certify and Increase Opportunity. Be Govt. Certified Blackberry Apps Developer Touch event handling Touch Event properties Touch event phases Touch Point ID Basic touch events are handled the same way you handle other events, like mouse events, in ActionScript. You can listen for a series of touch events defined by the event type constants in&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[3346],"tags":[4363],"class_list":["post-28591","page","type-page","status-publish","hentry","category-blackberry-apps","tag-handling-clicks-and-touch-events"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Handling clicks and touch events - Tutorial<\/title>\n<meta name=\"description\" content=\"Handling clicks and touch events. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Handling clicks and touch events - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Handling clicks and touch events. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:46:11+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/\",\"name\":\"Handling clicks and touch events - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-06-27T08:59:40+00:00\",\"dateModified\":\"2024-04-12T08:46:11+00:00\",\"description\":\"Handling clicks and touch events. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Handling clicks and touch events\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Handling clicks and touch events - Tutorial","description":"Handling clicks and touch events. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/","og_locale":"en_US","og_type":"article","og_title":"Handling clicks and touch events - Tutorial","og_description":"Handling clicks and touch events. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:46:11+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/","name":"Handling clicks and touch events - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-06-27T08:59:40+00:00","dateModified":"2024-04-12T08:46:11+00:00","description":"Handling clicks and touch events. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/handling-clicks-and-touch-events\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Handling clicks and touch events"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/28591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=28591"}],"version-history":[{"count":5,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/28591\/revisions"}],"predecessor-version":[{"id":64853,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/28591\/revisions\/64853"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=28591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=28591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=28591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}