
{"id":362,"date":"2007-09-23T08:31:16","date_gmt":"2007-09-23T07:31:16","guid":{"rendered":"http:\/\/www.matthijskamstra.nl\/blog\/index.php\/2007\/09\/23\/as3-take-one-step-at-a-time-step-1a\/"},"modified":"2007-12-04T18:07:42","modified_gmt":"2007-12-04T17:07:42","slug":"as3-take-one-step-at-a-time-step-1a","status":"publish","type":"post","link":"https:\/\/www.matthijskamstra.nl\/blog\/2007\/09\/23\/as3-take-one-step-at-a-time-step-1a\/","title":{"rendered":"AS3 &#8211; take one step at a time: step 1a"},"content":{"rendered":"<div class=\"highlight\">I&#8217;ve made a mistake, the code I original wrote doesn&#8217;t work (I&#8217;m glad nobody noticed it \ud83d\ude09 ). You can find the correct class <a href='#correctStageClass'>here<\/a><\/div>\n<p>My <a href=\"http:\/\/www.matthijskamstra.nl\/blog\/index.php\/2007\/09\/22\/as3-take-one-step-at-a-time-step-1\/\">previous post<\/a> is about my first step into ActionScript 3 (AS3) and in my case: trail and error is the best way to learn stuff.<\/p>\n<p>But it takes some time to find out and sometimes it&#8217;s nice to have some help.<\/p>\n<p>I found some help to fix this in the future : Patrick Mineault at <a href=\"http:\/\/www.5etdemi.com\/convert\/\">5 1\/2 blog<\/a> has created a <a href=\"http:\/\/www.5etdemi.com\/blog\/archives\/2006\/11\/as2-to-as3-converter-createtextfield-geturl-handling\/\">AS2 to AS3 converter<\/a> which you can <a href=\"http:\/\/www.5etdemi.com\/convert\/\">test here<\/a> and <a href=\"http:\/\/www.5etdemi.com\/convert\/convert.zip\">download here<\/a>.<\/p>\n<p>There is a web form to paste your code into and it will return your converted AS3 code (<a href=\"http:\/\/www.5etdemi.com\/convert\/\">check it here<\/a>).<br \/>\nThere is also an command line exe in the <a href=\"http:\/\/www.5etdemi.com\/convert\/convert.zip\">zip file<\/a><br \/>\nI&#8217;m not very good at command line, so for your (and mine) convenience I will explain how to get the exe to work with a .BAT file (I work on a PC so the example only works on PC).<\/p>\n<p>Download the <a href=\"http:\/\/www.5etdemi.com\/convert\/convert.zip\">zip file<\/a> and extract it somewhere on your computer. In my case <code>C:\\tmp\\convert<\/code><br \/>\nI&#8217;ve created to folders in the convert folder<br \/>\n<code>C:\\tmp\\convert\\input<br \/>\nC:\\tmp\\convert\\output<\/code><br \/>\nand in the input folder I copied all the classes I&#8217;ve ever written.<\/p>\n<p>Now create a file with a .BAT extension (in my case <code>convert.bat<\/code>) and it doesn&#8217;t matter where you put it, but I put it next to the <code>convertas2as3.exe<\/code> in <code>C:\\tmp\\convert<\/code> folder.<\/p>\n<p>Open the file you just created and paste this in there:<br \/>\n<code><br \/>\npause<br \/>\nC:\\tmp\\convert\\convertas2as3.exe -input \"C:\\tmp\\convert\\input\" -output \"C:\\tmp\\convert\\output\"<br \/>\n<\/code><\/p>\n<p>or adjust the path to the files you want to convert<br \/>\nsave the file and open the .BAT file (in my case <code>convert.bat<\/code>) and all your classes you ever have written are converted to AS3&#8230;<\/p>\n<p>Well as good as it get&#8217;s: it&#8217;s not 100 percent converted to AS3 but it helps you with most of your code, and helps you on your way to find the correct code.<\/p>\n<p><strong>example <\/strong><br \/>\ntake the code I translated in the previous post but now in a class file:<\/p>\n<div class=\"showcode\">\n<pre>class nl.matthijskamstra.config.ConfigFile\r\n{\r\n\t\/**\r\n\t* Constructor \r\n\t* To access and manipulate information about the boundaries of a SWF file.\r\n\t*\/\r\n\tpublic function ConfigFile ()\r\n\t{\r\n\t\t\/\/ trace (\"set flash to 'browser'-mode\");\r\n\t\t_root._quality = \"BEST\";\r\n\t\tStage.scaleMode = \"noScale\";\r\n\t\tStage.showMenu = false;\r\n\t\tStage.align = \"TL\";\r\n\t}\r\n\t\/**\r\n\t* static function config.... same as above\r\n\t*\r\n\t* @usage   nl.matthijskamstra.config.ConfigFile.config ();\r\n\t*\/\r\n\tstatic function config () : Void\r\n\t{\r\n\t\tvar temp = new nl.matthijskamstra.config.ConfigFile ();\r\n\t}\r\n}\r\n<\/pre>\n<\/div>\n<p>and put it through the <a href=\"http:\/\/www.5etdemi.com\/convert\/\">AS2 to AS3 online converter<\/a> will become:<\/p>\n<div class=\"showcode\">\n<pre>package  { \r\nclass nl.matthijskamstra.config.ConfigFile\r\n\timport flash.ui.ContextMenu;\r\n\timport flash.display.Stage;\r\n\t{\r\n\t\t\/**\r\n\t\t* Constructor \r\n\t\t* To access and manipulate information about the boundaries of a SWF file.\r\n\t\t*\/\r\n\t\tpublic function ConfigFile ()\r\n\t\t{\r\n\t\t\t\/\/ trace (\"set flash to 'browser'-mode\");\r\n\t\t\t_root._quality = \"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\t* static function config.... same as above\r\n\t\t*\r\n\t\t* @usage   nl.matthijskamstra.config.ConfigFile.config ();\r\n\t\t*\/\r\n\t\tstatic public function config () : void\r\n\t\t{\r\n\t\t\tvar temp = new nl.matthijskamstra.config.ConfigFile ();\r\n\t\t}\r\n\t}\r\n\t\r\n}\r\n<\/pre>\n<\/div>\n<p>this will not work without errors but will help you convert your AS2 code to AS3<\/p>\n<div class=\"showcode\">\n<pre>\r\npackage nl.matthijskamstra.config {\r\n\r\n\timport flash.display.MovieClip;\t\r\n\timport flash.display.Stage;\r\n\timport flash.display.StageQuality;\r\n\r\n\tpublic class ConfigFile extends MovieClip {\r\n\t\t\/**\r\n\t\t* Constructor \r\n\t\t* To access and manipulate information about the boundaries of a SWF file.\r\n\t\t*\/\r\n\t\tpublic function ConfigFile () {\r\n\t\t\ttrace ('ConfigFile ')\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\t* static function config.... same as above\r\n\t\t*\r\n\t\t* @usage   nl.matthijskamstra.config.ConfigFile.config ();\r\n\t\t*\/\r\n\t\tstatic public function config () : void\r\n\t\t{\r\n\t\t\tvar temp = new nl.matthijskamstra.config.ConfigFile ();\r\n\t\t}\t\t\r\n\t}\r\n\r\n\t\r\n}\r\n<\/pre>\n<\/div>\n<div id='correctStageClass' >\n<br \/>\n<strong>The config class that works!<\/strong><br \/>\n\n<\/div>\n<div class=\"showcode\">\n<pre>package nl.matthijskamstra.config {\r\n\t\r\n\timport flash.display.MovieClip;\t\r\n\timport flash.display.StageQuality;\r\n\r\n\tpublic class ConfigFile extends MovieClip {\r\n\t\t\r\n\t\t\/\/ Constants:\r\n\t\tpublic static var CLASS_REF = nl.matthijskamstra.config.ConfigFile;\r\n\t\tpublic static var CLASS_NAME : String = \"ConfigFile\";\r\n\t\tpublic static var LINKAGE_ID : String = \"nl.matthijskamstra.config.ConfigFile\";\r\n\t\t\r\n\t\t\/**\r\n\t\t* Constructor\r\n\t\t* \r\n\t\t* @usage   \timport nl.matthijskamstra.config.ConfigFile; \/\/ import\r\n\t\t*\t\t\tvar __ConfigFile__ : ConfigFile = new ConfigFile ( this );\r\n\t\t* @param\t$target_mc\t\ta reference to a movie clip or object\r\n\t\t*\/\r\n\t\tpublic function ConfigFile( $target_mc:MovieClip = null ) {\r\n\t\t\t\/\/ trace ( '+ ' + LINKAGE_ID + ' class instantiated');\r\n\t\t\t$target_mc.stage.quality = StageQuality.BEST;\r\n\t\t\t$target_mc.stage.scaleMode = \"noScale\";\r\n\t\t\t$target_mc.stage.showDefaultContextMenu = false;\r\n\t\t\t$target_mc.stage.align = \"TL\";\r\n\t\t}\r\n\t\t\r\n\t\t\/**\r\n\t\t* static function config.... same as above\r\n\t\t*\r\n\t\t* @usage  \tnl.matthijskamstra.config.ConfigFile.config(this);\r\n\t\t* \t\t\tConfigFile.config (this);\r\n\t\t* @param\t$target_mc\t\ta reference to a movie clip or object\t\r\n\t\t*\/\r\n\t\tstatic public function config ($target_mc:MovieClip ) : void {\r\n\t\t\tvar __config = new nl.matthijskamstra.config.ConfigFile ($target_mc);\r\n\t\t}\r\n\t\t\r\n\t} \/\/ end class\r\n\t\r\n} \/\/ end package<\/pre>\n<\/div>\n<p>I&#8217;m sorry for adding to the confusion which happens when you learn ActionScript 3!<br \/>\nThe Stage class is a difficult change from AS2 to AS3, when I have some time I will explain.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve made a mistake, the code I original wrote doesn&#8217;t work (I&#8217;m glad nobody noticed it \ud83d\ude09 ). You can find the correct class here My previous post is about my first step into ActionScript 3 (AS3) and in my case: trail and error is the best way to learn stuff. But it takes some [&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-362","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\/362","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=362"}],"version-history":[{"count":0,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/362\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/media?parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/categories?post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/tags?post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}