{"id":44,"date":"2008-04-01T08:48:04","date_gmt":"2008-04-01T08:48:04","guid":{"rendered":"http:\/\/todepoint.com\/blog\/?p=44"},"modified":"2008-04-01T08:48:04","modified_gmt":"2008-04-01T08:48:04","slug":"resizemanager-simple-scaling-engine","status":"publish","type":"post","link":"https:\/\/todepoint.com\/blog\/2008\/04\/01\/resizemanager-simple-scaling-engine\/","title":{"rendered":"ResizeManager &#8211; simple scaling engine for MovieClips"},"content":{"rendered":"<p>Flash objects (SWF) can fill the entire Html body, and scale along with browser window as you resize it (it&#8217;s done by setting <strong>width<\/strong> and <strong>height<\/strong> attributes to 100% in the embed tags).  However unless <a herf=\"http:\/\/livedocs.adobe.com\/flash\/9.0\/main\/00002154.html\" target=\"_blank\" title=\"scaleMode in Livedocs\">scaleMode<\/a> is properly defined as well, the outcome may look surprisingly bad, the flash content may loose proportions and distort, images quality drops and texts loose readability.. oh man.<\/p>\n<p>Only specific contents should be scaled when the stage is resized, the same way apps handles resizing: an app will redistribute its panels without scaling them, will scale panel background but not the buttons and the controls in it. When the entire stage is simply scaled, the interface balance is disturbed.. and we don&#8217;t want that.<\/p>\n<p>So I decided to share: <strong>ResizeManager<\/strong> (<a href=\"http:\/\/www.todepoint.com\/adi\/as_examples\/ResizeManager\/com.zip\" title=\"Download ResizeManager class\">download<\/a>) is a very simple scaling engine, a single AS2 class that can easily be modified or extended for your needs.<br \/>\nThe manger can control <strong>scaling<\/strong> and some basic <strong>align<\/strong> options of MovieClips you register to it, so you can scale a background MovieClip to cover the entire stage, and keep another MovieClip centered without scaling. It also adds default definitions for the Stage behavior (scaleMode: noScale, stageAlign: TL), though you can change those.<br \/>\nIn order to use it, simply import the class and create an instance of the ResizeManager:<br \/>\n<code><br \/>\nimport com.adifeiwel.custom_ui.ResizeManager;<\/p>\n<p>var rm = new ResizeManager();<br \/>\n<\/code><\/p>\n<p>Then, use method <strong>registerMC()<\/strong> to register each MovieClip you want to control (including MovieClips nested within MovieClips, make sure parent MC is x:0, y:0), the registerMC method expects the following parameters:<br \/>\n <code><strong>_parentName<\/strong>:MovieClip<\/code> (the name of the MoviClip)<br \/>\n <code><strong>_widthUpdate<\/strong>:Number<\/code> (scaling in percentage from Stage.width, 0 for no-scale)<br \/>\n <code><strong>_heightUpdate<\/strong>:Number<\/code> (scaling in percentage from Stage.height, 0 for no-scale)<br \/>\n <code><strong>_centerUpdate<\/strong>:Boolean<\/code> (align MovieClip to center of stage)<br \/>\n <code><strong>_middleUpdate<\/strong>:Boolean<\/code> (vertical-align MovieClip to middle of stage)<\/p>\n<p>for example (<a href=\"http:\/\/www.todepoint.com\/adi\/as_examples\/ResizeManager\/\" target=\"_blank\" title=\"ResizeManager example\" alt=\"ResizeManager example\">see it here<\/a>):<br \/>\n<code><br \/>\nrm.registerMC(portMC.mainBG, 100, 100, false, false);<br \/>\n\/\/ will scale to cover all Stage<\/p>\n<p>rm.registerMC(portMC.middleMC.middleBG, 100, 0, false, false);<br \/>\n\/\/ will scale to take 100% of Stage.width<\/p>\n<p>rm.registerMC(portMC.middleMC.middleContentMC, 0, 0, true, false);<br \/>\n\/\/ aligned to center<\/p>\n<p>rm.registerMC(portMC.transMC, 0, 0, true, true);<br \/>\n\/\/ aligned to center, vertical-align to middle.<\/p>\n<p>rm.registerMC(portMC.vClip, 0, 80, false, false);<br \/>\n\/\/ will scale to take 80% of Stage.height<br \/>\n<\/code><\/p>\n<p>enjoy : )<\/p>\n<p><strong>Update:<\/strong> You can <a href=\"http:\/\/www.todepoint.com\/adi\/as_examples\/ResizeManager\/scaleable01.fla.zip\" title=\"download ResizeManager FLA example\" alt=\"download ResizeManager FLA example\">download the example FLA here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flash objects (SWF) can fill the entire Html body, and scale along with browser window as you resize it (it&#8217;s done by setting width and height attributes to 100% in the embed tags). However unless scaleMode is properly defined as well, the outcome may look&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,10,16,29],"tags":[],"_links":{"self":[{"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/posts\/44"}],"collection":[{"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":0,"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"wp:attachment":[{"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/todepoint.com\/blog\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}