{"id":235,"date":"2009-03-28T00:00:39","date_gmt":"2009-03-28T07:00:39","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1071"},"modified":"2009-03-28T00:00:39","modified_gmt":"2009-03-28T07:00:39","slug":"var-objobject-new-function","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=235","title":{"rendered":"var obj:Object = new Function()"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar Pnt:Function = function(xp:Number, yp:Number){\r\n\t\r\n\tvar x:Number = xp;\r\n\tvar y:Number = yp\r\n\t\r\n\tthis.setX = function(v:int):void{\r\n\t\tx = v;\r\n\t}\r\n\tthis.setY = function(v:int):void{\r\n\t\ty = v;\r\n\t}\r\n\tthis.getX = function():int {\r\n\t\treturn x;\r\n\t}\r\n\tthis.getY = function():int {\r\n\t\treturn y;\r\n\t}\r\n}\r\n\r\nvar p:Object = new Pnt(10,10);\r\n\r\ntrace(p.getX(), p.getY());\r\np.setX(100);\r\ntrace(p.getX());\r\n\r\n\/*\r\noutputs:\r\n10, 10\r\n100\r\n*\/\r\n<\/pre>\n<p>Another way to define and instantiate Objects on the timeline. Interesting, but I don&#8217;t recommend it over actual classes&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var Pnt:Function = function(xp:Number, yp:Number){ var x:Number = xp; var y:Number = yp this.setX = function(v:int):void{ x = v; } this.setY = function(v:int):void{ y = v; } this.getX = function():int { return x; } this.getY = function():int { return y; } } var p:Object = new Pnt(10,10); trace(p.getX(), p.getY()); p.setX(100); trace(p.getX()); \/* outputs: 10, 10 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,7,2],"tags":[3,4],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-functions","category-object","category-oop","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}