{"id":725,"date":"2010-01-09T18:17:14","date_gmt":"2010-01-09T18:17:14","guid":{"rendered":"http:\/\/www.thisisgameplay.com\/?p=725"},"modified":"2024-07-19T09:35:03","modified_gmt":"2024-07-19T07:35:03","slug":"orient-an-object-to-the-mouse-cursor","status":"publish","type":"post","link":"https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/","title":{"rendered":"ActionScript: Orient an object to the mouse cursor with Flash"},"content":{"rendered":"<p>Voici comment orienter un objet graphique de type MovieClip en Flash vers le curseur de la souris.<br \/>\nCopier\/Coller le script dans Flash et remplacer le nom d&rsquo;instance myTank par le v\u00f4tre.<\/p>\n<p>[swf:\/wp-content\/uploads\/2010\/01\/Orienter_un_objet_par_rapport_a_un_autre-1.swf 300 300]<\/p>\n<pre class=\"brush:as3\">\/\/ Cet objet regardera tout le temps le curseur\r\nmyTank.addEventListener(Event.ENTER_FRAME, tankEnterFrame);\r\n\/\/ Cette fonction est lanc\u00e9e \u00e0 chaque frame 25 fois par seconde.;\r\nfunction tankEnterFrame(pEvt) {\r\n\t\/\/ pEvt.currentTarget = myTank\r\n\tvar mc = pEvt.currentTarget;\r\n\t\/\/ Calculer l'angle en radians entre les 2 objets\r\n\t\/\/ On peut aussi remplacer les coordonn\u00e9es de la souris par d'autres.\r\n\tvar angleRadian=Math.atan2(mouseY-mc.y,mouseX-mc.x);\r\n\t\/\/ Convertir l'angle radian en degr\u00e9s.\r\n\tvar angleDegree = angleRadian * 180 \/ Math.PI;\r\n\t\/\/ Orienter le symbole mc\r\n\tmc.rotation = angleDegree;\r\n\t\/\/ Afficher l'angle en degr\u00e9s sur l'interface\r\n\ttxtAngle.text = Math.round(angleDegree) + \"\u00b0\";\r\n}<\/pre>\n<p>T\u00e9l\u00e9charger les sources: <a href=\"https:\/\/benoitfreslon.com\/wp-content\/uploads\/2010\/01\/www.thisisgameplay.com_Orient_object_to_mouse_cursor.fla\">[www.thisisgameplay.com]_Orient_object_to_mouse_cursor.fla<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Voici comment orienter un objet graphique de type MovieClip en Flash vers le curseur de la souris. Copier\/Coller le script&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[36,39,410],"class_list":["post-725","post","type-post","status-publish","format-standard","hentry","category-news","tag-actionscript-3","tag-orientation","tag-souris","wpcat-1-id"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ActionScript: Orient an object to the mouse cursor with Flash - Beno\u00eet Freslon<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benoit Freslon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/\"},\"author\":{\"name\":\"Benoit Freslon\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/#\\\/schema\\\/person\\\/fe9fe28a6b6c2b56648448b977fd6b78\"},\"headline\":\"ActionScript: Orient an object to the mouse cursor with Flash\",\"datePublished\":\"2010-01-09T18:17:14+00:00\",\"dateModified\":\"2024-07-19T07:35:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/\"},\"wordCount\":116,\"keywords\":[\"actionscript 3\",\"orientation\",\"souris\"],\"articleSection\":[\"Actualit\u00e9s\"],\"inLanguage\":\"fr-FR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/\",\"url\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/\",\"name\":\"ActionScript: Orient an object to the mouse cursor with Flash - Beno\u00eet Freslon\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/#website\"},\"datePublished\":\"2010-01-09T18:17:14+00:00\",\"dateModified\":\"2024-07-19T07:35:03+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/#\\\/schema\\\/person\\\/fe9fe28a6b6c2b56648448b977fd6b78\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[[\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/\"]]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/orient-an-object-to-the-mouse-cursor\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ActionScript: Orient an object to the mouse cursor with Flash\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/#website\",\"url\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/\",\"name\":\"Beno\u00eet Freslon\",\"description\":\"[:en]Game designer | D\u00e9veloppeur de jeux ind\u00e9pendant | Freelance | Enseignant | Blogueur[:fr]Game designer | Independent game developer | Freelance | Teacher | Blogger[:]\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/#\\\/schema\\\/person\\\/fe9fe28a6b6c2b56648448b977fd6b78\",\"name\":\"Benoit Freslon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g\",\"caption\":\"Benoit Freslon\"},\"sameAs\":[\"https:\\\/\\\/benoitfreslon.com\",\"https:\\\/\\\/www.instagram.com\\\/benoitfreslon\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/benoitfreslon\",\"https:\\\/\\\/x.com\\\/BenoitFreslon\",\"https:\\\/\\\/www.youtube.com\\\/benoitfreslon\"],\"url\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ActionScript: Orient an object to the mouse cursor with Flash - Beno\u00eet Freslon","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:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/","twitter_misc":{"\u00c9crit par":"Benoit Freslon","Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/benoitfreslon.com\/news\/orient-an-object-to-the-mouse-cursor\/#article","isPartOf":{"@id":"https:\/\/benoitfreslon.com\/news\/orient-an-object-to-the-mouse-cursor\/"},"author":{"name":"Benoit Freslon","@id":"https:\/\/benoitfreslon.com\/#\/schema\/person\/fe9fe28a6b6c2b56648448b977fd6b78"},"headline":"ActionScript: Orient an object to the mouse cursor with Flash","datePublished":"2010-01-09T18:17:14+00:00","dateModified":"2024-07-19T07:35:03+00:00","mainEntityOfPage":{"@id":"https:\/\/benoitfreslon.com\/news\/orient-an-object-to-the-mouse-cursor\/"},"wordCount":116,"keywords":["actionscript 3","orientation","souris"],"articleSection":["Actualit\u00e9s"],"inLanguage":"fr-FR"},{"@type":"WebPage","@id":"https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/","url":"https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/","name":"ActionScript: Orient an object to the mouse cursor with Flash - Beno\u00eet Freslon","isPartOf":{"@id":"https:\/\/benoitfreslon.com\/fr\/#website"},"datePublished":"2010-01-09T18:17:14+00:00","dateModified":"2024-07-19T07:35:03+00:00","author":{"@id":"https:\/\/benoitfreslon.com\/#\/schema\/person\/fe9fe28a6b6c2b56648448b977fd6b78"},"breadcrumb":{"@id":"https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":[["https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/"]]}]},{"@type":"BreadcrumbList","@id":"https:\/\/benoitfreslon.com\/fr\/news\/orient-an-object-to-the-mouse-cursor\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/benoitfreslon.com\/fr\/"},{"@type":"ListItem","position":2,"name":"ActionScript: Orient an object to the mouse cursor with Flash"}]},{"@type":"WebSite","@id":"https:\/\/benoitfreslon.com\/fr\/#website","url":"https:\/\/benoitfreslon.com\/fr\/","name":"Beno\u00eet Freslon","description":"[:en]Game designer | D\u00e9veloppeur de jeux ind\u00e9pendant | Freelance | Enseignant | Blogueur[:fr]Game designer | Independent game developer | Freelance | Teacher | Blogger[:]","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/benoitfreslon.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Person","@id":"https:\/\/benoitfreslon.com\/#\/schema\/person\/fe9fe28a6b6c2b56648448b977fd6b78","name":"Benoit Freslon","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/secure.gravatar.com\/avatar\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g","caption":"Benoit Freslon"},"sameAs":["https:\/\/benoitfreslon.com","https:\/\/www.instagram.com\/benoitfreslon","https:\/\/www.linkedin.com\/in\/benoitfreslon","https:\/\/x.com\/BenoitFreslon","https:\/\/www.youtube.com\/benoitfreslon"],"url":"https:\/\/benoitfreslon.com\/fr\/author\/admin\/"}]}},"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pLAe3-bH","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts\/725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/comments?post=725"}],"version-history":[{"count":69,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts\/725\/revisions"}],"predecessor-version":[{"id":39134,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts\/725\/revisions\/39134"}],"wp:attachment":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/media?parent=725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/categories?post=725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/tags?post=725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}