{"id":8779,"date":"2014-08-12T19:19:49","date_gmt":"2014-08-12T19:19:49","guid":{"rendered":"http:\/\/2slick.com\/web\/?p=8779"},"modified":"2014-08-12T19:22:27","modified_gmt":"2014-08-12T19:22:27","slug":"how-to-find-the-screen-size-in-as3","status":"publish","type":"post","link":"https:\/\/2slick.com\/web\/how-to-find-the-screen-size-in-as3\/affordablewebsitestips\/tutorials","title":{"rendered":"How to find the screen size of the device using AS3"},"content":{"rendered":"<p>The code below will display the size of the current device screen that the SWF is run on. This also works as an AIR application. In order for this code to work, you will need to create a text field on the stage with the instance name of 'sizeTxt'. Also make sure the Text field is set to 'Dynamic Text'. Insert the code below on frame 1 of the flash project's timeline.<\/p>\n<p><!--DEVFMTCODE--><pre class=\"devcodeblock\" title=\"Javascript\"><table class=\"devcodetools\"><tbody><tr><td>&nbsp;Javascript&nbsp;|&nbsp;<\/td><td style=\"background-image:url('https:\/\/2slick.com\/web\/wp-content\/plugins\/devformatter\/img\/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;\"\/><embed id=\"ZeroClipboard1\" src=\"https:\/\/2slick.com\/web\/wp-content\/plugins\/devformatter\/_zclipboard.swf\" loop=\"false\" menu=\"false\" quality=\"best\" bgcolor=\"#ffffff\" width=\"16px\" height=\"16px\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" flashvars=\"id=1&width=16&height=16\" wmode=\"transparent\" \/><\/td><td>&nbsp;copy&nbsp;code&nbsp;|<\/td><td style=\"cursor:pointer\" title=\"DevFormatter Plugin\" onclick=\"devfmt_credits()\">?<\/td><td width=\"99%\">&nbsp;<\/td><\/tr><\/tbody><\/table><div class=\"devcodeoverflow\"><table class=\"devcodearea\" width=\"100%\"><tr><td class=\"devcodelines\" width=\"1%\">1<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\"><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">2<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\"><span style=\"color: #003366; font-weight: bold;\">import<\/span> flash.<span style=\"color: #660066;\">system<\/span>.<span style=\"color: #660066;\">Capabilities<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">3<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">&nbsp;<\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">4<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\"><span style=\"color: #003366; font-weight: bold;\">var<\/span> screenWidth<span style=\"color: #339933;\">:<\/span>Number <span style=\"color: #339933;\">=<\/span> Capabilities.<span style=\"color: #660066;\">screenResolutionX<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">5<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\"><span style=\"color: #003366; font-weight: bold;\">var<\/span> screenHeight<span style=\"color: #339933;\">:<\/span>Number <span style=\"color: #339933;\">=<\/span> Capabilities.<span style=\"color: #660066;\">screenResolutionY<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><tr><td class=\"devcodelines devcodelinesodd devcodelinesodd\" width=\"1%\">6<\/td><td class=\"devcodelinesarea devcodelinesareaodd devcodelinesareaodd\"><pre class=\"devcode devcodeline\">&nbsp;<\/pre><\/td><\/tr><tr><td class=\"devcodelines\" width=\"1%\">7<\/td><td class=\"devcodelinesarea\"><pre class=\"devcode devcodeline\">\tsizeTxt.<span style=\"color: #660066;\">text<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #3366CC;\">&quot;sw2:&quot;<\/span><span style=\"color: #339933;\">+<\/span>screenWidth<span style=\"color: #339933;\">+<\/span><span style=\"color: #3366CC;\">&quot; sH2:&quot;<\/span><span style=\"color: #339933;\">+<\/span>screenHeight<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><\/pre><\/td><\/tr><\/table><\/div><\/pre><!--END_DEVFMTCODE--> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The code below will display the size of the current device screen that the SWF is run on. This also works as an AIR application. In order for this code to work, you will need to create a text field on the stage with the instance name of &#8216;sizeTxt&#8217;. Also make sure the Text field [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[742,734,735],"class_list":["post-8779","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-adobe-air","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/comments?post=8779"}],"version-history":[{"count":6,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8779\/revisions"}],"predecessor-version":[{"id":8785,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8779\/revisions\/8785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/media\/8748"}],"wp:attachment":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/media?parent=8779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/categories?post=8779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/tags?post=8779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}