{"id":228,"date":"2007-12-31T16:35:32","date_gmt":"2007-12-31T07:35:32","guid":{"rendered":"http:\/\/hangunsworld.com\/blog\/228"},"modified":"2011-03-24T00:53:44","modified_gmt":"2011-03-23T15:53:44","slug":"addedtostage-event-object-and-root-parent","status":"publish","type":"post","link":"http:\/\/hangunsworld.com\/blog\/228","title":{"rendered":"AddedToStage event object and root, parent."},"content":{"rendered":"<div class=\"english\">In AS3, There are times that you can not use root or parent properties on a display object. It is because root and parent properties are set to null, unless they are not added to the stage. So, an error occurs when you try to use root or parent properties in the constructor of an class. To avoid this problem, use addedToStage event object, and run codes after a display object was added to the display list.<\/div>\n<div class=\"korean\">AS3\uc758 \ub514\uc2a4\ud50c\ub808\uc774 \uc624\ube0c\uc81d\ud2b8\uc5d0\uc11c root \ub610\ub294 parent \uc18d\uc131\uc744 \ucc38\uc870\ud558\uc9c0 \ubabb\ud558\ub294 \uacbd\uc6b0\uac00 \uc885\uc885 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub294 root \ubc0f parent \uc18d\uc131\uc740 \ub514\uc2a4\ud50c\ub808\uc774 \uc624\ube0c\uc81d\ud2b8\uac00 \uc2a4\ud14c\uc774\uc9c0\uc5d0 \uc560\ub4dc\ub418\uc9c0 \uc54a\uc73c\uba74 null \uac12\uc744 \uac00\uc9c0\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4. \uadf8\ub7ec\ubbc0\ub85c \ud074\ub798\uc2a4 \ucee8\uc2a4\ud2b8\ub7ed\ud130\uc5d0\uc11c root \ub610\ub294 parent\ub97c \ucc38\uc870\ud558\ub824 \ud560 \ub54c \uc5d0\ub7ec\uac00 \ubc1c\uc0dd\ud558\ub294 \uac83\uc785\ub2c8\ub2e4. \uc774\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574\uc11c addedToStage \uc774\ubca4\ud2b8 \uc624\ube0c\uc81d\ud2b8\ub97c \uc0ac\uc6a9\ud558\uc5ec, \ub514\uc2a4\ud50c\ub808\uc774 \uc624\ube0c\uc81d\ud2b8\uac00 \ub514\uc2a4\ud50c\ub808\uc774 \ub9ac\uc2a4\ud2b8\uc5d0 \ucd94\uac00\ub418\uc5c8\uc744 \ub54c \ud544\uc694\ud55c \ucf54\ub4dc\ub97c \uc2e4\ud589\ud558\ub3c4\ub85d \ud558\uba74 \ub429\ub2c8\ub2e4.<\/div>\n<div class=\"japanese\">AS3\u3067\u3001\u30c7\u30a3\u30b9\u30d7\u30ec\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304croot\u3084parent\u30d7\u30ed\u30d1 \u30c6\u30a3\u3092\u53c2\u7167\u3067\u304d\u306a\u3044\u6642\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u306f\u3001\u30c7\u30a3\u30b9\u30d7\u30ec\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u30b9\u30c6\u2015\u30b8\u306b\u8ffd\u52a0\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u3001root\u3068parent\u30d7\u30ed\u30d1 \u30c6\u30a3\u306fnull\u306b\u8a2d\u5b9a\u3055\u308c\u308b\u3068\u8a00\u3046\u308f\u3051\u3067\u3059\u3002\u3060\u304b\u3089\u3001\u30af\u30e9\u30b9\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u4e2d\u3067root\u3084parent\u30d7\u30ed\u30d1 \u30c6\u30a3\u53c2\u7167\u3057\u3088\u3046\u3068\u3059\u308b\u6642\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306e\u3067\u3059\u3002\u3053\u306e\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3059\u308b\u305f\u3081\u306b\u3001addedToStage\u30a4\u30d9\u30f3\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f7f\u7528\u3057\u3001\u30c7\u30a3\u30b9\u30d7\u30ec\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u30c7\u30a3\u30b9\u30d7\u30ec\u30fc\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3055\u308c\u305f\u6642\u3001\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/div>\n<blockquote><p>root property<br \/>\nroot:DisplayObject [read-only]<\/p>\n<p>&#8230;&#8230; The root property is set to null for any display object that has not been added to the display list, unless it has been added to a display object container that is off the display list but that is a child of the top-most display object in a loaded SWF file.<\/p>\n<p>quote from ActionScript 3.0 Language and Components Reference<\/p><\/blockquote>\n<div class=\"english\">The following codes are the codes that I use frequently. I choose _root and _parent keywords that are not used in AS3.<\/div>\n<div class=\"korean\">\ub2e4\uc74c \ucf54\ub4dc\ub294 \uc81c\uac00 \uc790\uc8fc \uc0ac\uc6a9\ud558\ub294 \ucf54\ub4dc\ub85c, AS3\uc5d0\uc11c\ub294 \uc0ac\uc6a9\ub418\uc9c0 \uc54a\ub294 _root, _parent \ud0a4\uc6cc\ub4dc\ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4.<\/div>\n<div class=\"japanese\">\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u79c1\u304c\u3088\u304f\u4f7f\u3046\u3053\u30fc\u3069\u3067\u3001\u79c1\u306fAS3\u3067\u306f\u4f7f\u308f\u306a\u3044_root\u3068_parent\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u9078\u3073\u307e\u3057\u305f\u3002<\/div>\n<pre lang=\"actionscript3\" line=\"1\">package{\r\n\t\r\n\timport\tflash.display.MovieClip;\r\n\timport\tflash.events.Event;\/\/ added on 2011.03.24\r\n\t\r\n\tpublic class SomeClass extends MovieClip{\r\n\t\t\r\n\t\tprivate var _root:MovieClip;\r\n\t\tprivate var _parent:MovieClip;\r\n\t\t\r\n\t\tpublic function SomeClass(){\r\n\t\t\t\r\n\t\t\taddEventListener(Event.ADDED_TO_STAGE, initialize);\r\n\t\t\t\r\n\t\t}\/\/ end SomeClass constructor\r\n\t\t\r\n\t\t\r\n\t\t\/**\r\n\t\t * Initializes the SomeClass, when an instance is added to the display list\r\n\t\t *\/\r\n\t\tprivate function initialize(evt:Event):void{\r\n\t\t\t\r\n\t\t\tremoveEventListener(Event.ADDED_TO_STAGE, initialize);\r\n\t\t\t\r\n\t\t\t_root = root as MovieClip;\r\n\t\t\t_parent = parent as MovieClip;\r\n\t\t\t\r\n\t\t}\/\/ end initialize\r\n\t\t\r\n\t}\/\/ end SomeClass definition\r\n\t\r\n}\/\/ end package<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In AS3, There are times that you can not use root or parent properties on a display object. It is because root and parent properties are set to null, unless they are not added to the stage. So, an error occurs when you try to use root or parent properties in the constructor of an [&hellip;]<\/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,58,57,59],"class_list":["post-228","post","type-post","status-publish","format-standard","hentry","category-as3","tag-actionscript-30","tag-addedtostage","tag-displayobject","tag-root"],"_links":{"self":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/228","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=228"}],"version-history":[{"count":1,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":873,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/posts\/228\/revisions\/873"}],"wp:attachment":[{"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hangunsworld.com\/blog\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}