
{"id":359,"date":"2007-09-22T08:31:11","date_gmt":"2007-09-22T07:31:11","guid":{"rendered":"http:\/\/www.matthijskamstra.nl\/blog\/index.php\/2007\/09\/24\/as3-take-one-step-at-a-time-step-1\/"},"modified":"2007-10-22T20:22:15","modified_gmt":"2007-10-22T19:22:15","slug":"as3-take-one-step-at-a-time-step-1","status":"publish","type":"post","link":"https:\/\/www.matthijskamstra.nl\/blog\/2007\/09\/22\/as3-take-one-step-at-a-time-step-1\/","title":{"rendered":"AS3 &#8211; take one step at a time: step 1"},"content":{"rendered":"<p>I finally started programming with ActionScript 3 (AS3); I know, I <strong>not<\/strong> a early adopter&#8230; \ud83d\ude09<\/p>\n<p>And the first steps in AS3 are as uncomfortable as the first time I started <a href=\"http:\/\/en.wikipedia.org\/wiki\/Object-oriented_programming\" title='Wikipedia knows best' >OOP<\/a> programming &#8230; or when I started moved from AS1 to AS2&#8230;<\/p>\n<p>Since I started working for <a href=\"http:\/\/www.makesomenoise.nl\/\" title=\"Make some NOISE\" >NOISE<\/a> 5 months ago and moved to Amsterdam, I haven&#8217;t had time to do learn AS3.<br \/>\nThat luckily has changed \ud83d\ude42 and I started learning the basics.<\/p>\n<p>And the first obstacle I ran into was something very simple: I always use a basic document (FLA) with default library items, some layers I always use and some ActionScript code to align the stage:<br \/>\n<code><br \/>\n_root._quality = \"BEST\";<br \/>\nStage.scaleMode = \"noScale\";<br \/>\nStage.showMenu = false;<br \/>\nStage.align = \"TL\";<br \/>\nstop ();<br \/>\n<\/code><br \/>\nI have this also in a class (AS2), so I thought it would be useful to rewrite this class in AS3.<br \/>\nand I wanted to use this in my new as3 files too&#8230; (remember that this is the first thing a tried)<\/p>\n<p>First you need to create a document class:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/curtismorley.com\/wp-content\/uploads\/2007\/07\/documentclasspath.JPG\" alt=\"Document Class\" \/><br \/>\nAnd in my case my document class was: &#8216;Main&#8217;<\/p>\n<pre><code>\r\npackage  {\r\n\r\n\tpublic class Main {\r\n\t\t\r\n\t\tpublic function Main() {\r\n\t\t\ttrace ('Main')\t\t\t\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>(package generated by FlashDevelop)<\/p>\n<p>Code didn&#8217;t pass; I got a Compiler Error:<br \/>\n<code>5000: The class 'Main' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.<\/code><\/p>\n<pre><code>\r\npackage  {\r\n\r\n\tpublic class Main extends MovieClip {\r\n\t\t\r\n\t\tpublic function Main() {\r\n\t\t\ttrace ('Main')\t\t\t\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n}\r\n\r\n<\/code><\/pre>\n<p>I got some new errors:<\/p>\n<ol>\n<li>1017: The definition of base class MovieClip was not found.<\/li>\n<li>5000: The class &#8216;Main&#8217; must subclass &#8216;flash.display.MovieClip&#8217; since it is linked to a library symbol of that type.<\/li>\n<\/ol>\n<p>So I added <code>import flash.display.MovieClip;<\/code><\/p>\n<pre><code>\r\npackage  {\r\n\r\n\timport flash.display.MovieClip;\r\n\t\r\n\tpublic class Main extends MovieClip {\r\n\t\t\r\n\t\tpublic function Main() {\r\n\t\t\ttrace ('Main')\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>Ahhh and now we can get the stage to work with my &#8216;old code&#8217;, let&#8217;s paste it into the new document:<\/p>\n<pre><code>\r\npackage  {\r\n\r\n\timport flash.display.MovieClip;\r\n\t\r\n\tpublic class Main extends MovieClip {\r\n\t\t\r\n\t\tpublic function Main() {\r\n\t\t\ttrace ('Main')\r\n\t\t\t_root._quality = \"BEST\";\r\n\t\t\tStage.scaleMode = \"noScale\";\r\n\t\t\tStage.showMenu = false;\r\n\t\t\tStage.align = \"TL\";\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>Auw: both _root and Stage doesn&#8217;t excited no more: I got an <em>migration error<\/em><\/p>\n<pre><code>\r\npackage  {\r\n\r\n\timport flash.display.MovieClip;\t\r\n\timport flash.display.Stage;\r\n\timport flash.display.StageQuality;\r\n\t\r\n\tpublic class Main extends MovieClip {\r\n\t\t\r\n\t\tpublic function Main() {\r\n\t\t\ttrace ('Main')\r\n\t\t\tstage.quality = StageQuality.BEST;\r\n\t\t\tstage.scaleMode = \"noScale\";\r\n\t\t\tstage.showDefaultContextMenu = false;\r\n\t\t\tstage.align = \"TL\";\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>And at last it works&#8230;<br \/>\nThe only thing now to do, is to put it in the correct package.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally started programming with ActionScript 3 (AS3); I know, I not a early adopter&#8230; \ud83d\ude09 And the first steps in AS3 are as uncomfortable as the first time I started OOP programming &#8230; or when I started moved from AS1 to AS2&#8230; Since I started working for NOISE 5 months ago and moved to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,3],"tags":[68,39,97,408,398,114,168],"class_list":["post-359","post","type-post","status-publish","format-standard","hentry","category-as3","category-flash","tag-actionscript","tag-as2","tag-as2-to-as3","tag-as3","tag-flash","tag-from-as2-to-as3","tag-migration"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/comments?post=359"}],"version-history":[{"count":0,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/359\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/media?parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/categories?post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/tags?post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}