{"id":130,"date":"2007-06-08T11:15:59","date_gmt":"2007-06-08T02:15:59","guid":{"rendered":"http:\/\/hangunsworld.com\/blog\/?p=130"},"modified":"2008-10-15T23:06:06","modified_gmt":"2008-10-15T14:06:06","slug":"use-as-to-avoid-type-mis-match-error","status":"publish","type":"post","link":"http:\/\/hangunsworld.com\/blog\/130","title":{"rendered":"use &#8220;as&#8221; to avoid type mis-match error"},"content":{"rendered":"<pre lang=\"ActionScript3\" line=\"1\">for(var i:uint=0; i<numChildren; i++){\r\n\tvar mc:MovieClip = getChildAt(i);\r\n\ttrace(mc.x, mc.y);\r\n}<\/pre>\n<div class=\"english\">This code causes the type mis-match error at compile, because getChildAt() method returns a DisplayObject.<\/div>\n<div class=\"korean\">\uc704 \ucf54\ub4dc\ub294 \ucef4\ud30c\uc77c \uc2dc\uc5d0 \ub2e4\uc74c\uacfc \uac19\uc740 \ud0c0\uc785 \ubbf8\uc2a4\ub9e4\uce58 \uc5d0\ub7ec\ub97c \ub0c5\ub2c8\ub2e4. \uc65c\ub0d0\ud558\uba74 getChildAt()\uba54\uc18c\ub4dc\ub294 DisplayObject \uac1d\uccb4\ub97c \ub9ac\ud134\ud558\uae30 \ub54c\ubb38\uc774\uc8e0.<\/div>\n<blockquote><p>1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type flash.display:MovieClip.<\/p><\/blockquote>\n<div class=\"english\">To avoid the compile error, you can cast the returned value as MovieClip like this.<\/div>\n<div class=\"korean\">\uc774\ub7ec\ud55c \ucef4\ud30c\uc77c \uc5d0\ub7ec\ub97c \ud68c\ud53c\ud558\uae30 \uc704\ud574 \ub2e4\uc74c\uacfc \uac19\uc774 \ub9ac\ud134\ub41c \uac12\uc744 MovieClip\ub85c \uce90\uc2a4\ud305\ud569\ub2c8\ub2e4.<\/div>\n<pre lang=\"ActionScript3\" line=\"1\">var mc:MovieClip = MovieClip(getChildAt(i));<\/pre>\n<div class=\"english\">You can also use \"as\".<\/div>\n<div class=\"korean\">\ub610\ub294 \"as\"\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/div>\n<pre lang=\"ActionScript3\" line=\"1\">var mc:MovieClip = getChildAt(i) as MovieClip;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>for(var i:uint=0; i<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[139,161,52],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-as3","tag-actionscript-30","tag-casting","tag-type-mis-match"],"_links":{"self":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":0,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}