{"id":39,"date":"2008-04-11T21:51:24","date_gmt":"2008-04-11T19:51:24","guid":{"rendered":"http:\/\/blog.ansuz.nl\/index.php\/2008\/04\/11\/masks\/"},"modified":"2008-04-12T18:05:18","modified_gmt":"2008-04-12T16:05:18","slug":"masks","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2008\/04\/11\/masks\/","title":{"rendered":"Masks"},"content":{"rendered":"<p>The other day I was trying to animate a mask on a Sprite. It was working only very jerkily or not all. After a lot of trial and error I decided to re-read the docs on masking a Sprite. It turns out you need to add the mask to the the Stage before you can animate it. Quite strange when you are used to just setting the mask in ActionScript 2.<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000000;font-weight: bold\">var<\/span> mc:Sprite = <span style=\"color: #000000;font-weight: bold\">new<\/span> Sprite<span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ ... fill mc with something<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000000;font-weight: bold\">var<\/span> myMask:Sprite = <span style=\"color: #000000;font-weight: bold\">new<\/span> Sprite<span style=\"color: #66cc66\">&#040;<\/span><span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ ... draw the mask<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">addChild<span style=\"color: #66cc66\">&#040;<\/span>mc<span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">addChild<span style=\"color: #66cc66\">&#040;<\/span>mask<span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">mc.<span style=\"color: #006600\">mask<\/span> = myMask;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #808080;font-style: italic\">\/\/ .. now animate away!!! :)<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>The other day I was trying to animate a mask on a Sprite. It was working only very jerkily or not all. After a lot of trial and error I decided to re-read the docs on masking a Sprite. It &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2008\/04\/11\/masks\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[139],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-actionscript-30","tag-actionscript-30"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":0,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}