{"id":33,"date":"2008-08-08T10:11:23","date_gmt":"2008-08-08T17:11:23","guid":{"rendered":"http:\/\/www.nayansavla.com\/blog\/?p=33"},"modified":"2009-04-02T09:23:28","modified_gmt":"2009-04-02T16:23:28","slug":"understanding-scale-9-grid-for-flex","status":"publish","type":"post","link":"https:\/\/www.nayansavla.com\/blog\/?p=33","title":{"rendered":"Understanding Scale 9 grid for Flex"},"content":{"rendered":"<p>This article is for my reference as well because i always confused what co-ordinates i should use to specify the scale 9 grid i.e,\u00a0upSkin: Embed(source=&#8221;..\/assets\/graphics\/combobox\/ComboBox_upSkin.png&#8221;, scaleGridTop=&#8221;7&#8243;, scaleGridBottom=&#8221;10&#8243;, \tscaleGridLeft=&#8221;7&#8243;, scaleGridRight=&#8221;106&#8243;);<\/p>\n<p>I use the above skinning method a lot and hence need to completely understand how to specify the co-ordinates to scale the graphic to any extent.<\/p>\n<p>\u00a0<\/p>\n<p>If this all doesn&#8217;t make sense then i would ask you to read this <a href=\"http:\/\/www.adobe.com\/devnet\/flex\/quickstart\/embedding_assets\/\" target=\"_blank\">article<\/a>, it is awesome article but i was totally confused on how to find the correct co-ordinates for scaling.\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>Finally after lot of trials and errors i managed to get it right and understand it. I am going to show exactly how i calculate it. Take a look at the following picture,<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"vertical-align: middle;\" src=\"http:\/\/nayansavla.com\/uploads\/flash\/scalenine\/scale9.jpg\" alt=\"\" width=\"600\" height=\"414\" \/><\/p>\n<p>\u00a0<!-- google_ad_section_start --><\/p>\n<p>I am selecting the same fancy_border.png from the Adobe site and i am trying to find a rectangular region in the center which if scaled is not going to affect my image. This region begins at 53,54 and is 215&#215;82.<\/p>\n<p>\u00a0<\/p>\n<p>So now i need to assign my\u00a0scaleGridTop,\u00a0scaleGridBottom,\u00a0scaleGridLeft and\u00a0scaleGridRight from the above information,<\/p>\n<p>\u00a0<\/p>\n<p>scaleGridTop is the y position of this rectangle i.e.\u00a0scaleGridTop=54<\/p>\n<p>scaleGridBottom is the y position of this rectangle plus its height i.e\u00a0scaleGridBottom=54+82<\/p>\n<p>scaleGridLeft is the x position of this rectangle i.e\u00a0scaleGridLeft=53 and finally<\/p>\n<p>scaleGridRight is the x position of this rectangle plus its width i.e\u00a0scaleGridRight=53+215<\/p>\n<p>\u00a0<\/p>\n<p>so for the above image embed tag would like,<\/p>\n<p>\u00a0 [Embed(source=&#8221;..\/assets\/fancy_border.png&#8221;,<br \/>\nscaleGridTop=&#8221;54&#8243;, scaleGridBottom=&#8221;136&#8243;,<br \/>\nscaleGridLeft=&#8221;53&#8243;, scaleGridRight=&#8221;268&#8243;<br \/>\n)]<\/p>\n<p>\u00a0<\/p>\n<p>Flex scales this rectangular region when it scales the image, so your rectangle should be selected such that any distortion to this region won&#8217;t affect your original image. Also this rectangle will determine how much smaller your image can get without distortion, if you select a small rectangular region then you won&#8217;t be able to downsize your image.<\/p>\n<p>\u00a0<!-- google_ad_section_end --><\/p>\n<p>Hope this article makes the scale nine implementation in Flex more clear. Here is a swf file for you all to play with it applies two different scale nine grids to the same image and you will see the difference how it affects the downsizing of the image.\u00a0<\/p>\n<p>EDIT: 01\/15\/09<\/p>\n<p>Using 0 in the scaleGridTop doesn&#8217;t work, you have to use 1. I don&#8217;t know but it seems to be the case.<br \/>\n\u00a0<\/p>\n<p><a href=\"http:\/\/nayansavla.com\/uploads\/flash\/scalenine\/srcview\/\" target=\"_blank\">Click here<\/a> for the source.<\/p>\n<p>\u00a0<object width=\"600\" height=\"450\" data=\"http:\/\/nayansavla.com\/uploads\/flash\/scalenine\/scale9sample.swf\" type=\"application\/x-shockwave-flash\"><param name=\"wmode\" value=\"opaque\" \/><param name=\"src\" value=\"http:\/\/nayansavla.com\/uploads\/flash\/scalenine\/scale9sample.swf\" \/><\/object><\/p>\n<p>\u00a0<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is for my reference as well because i always confused what co-ordinates i should use to specify the scale 9 grid i.e,\u00a0upSkin: Embed(source=&#8221;..\/assets\/graphics\/combobox\/ComboBox_upSkin.png&#8221;, scaleGridTop=&#8221;7&#8243;, scaleGridBottom=&#8221;10&#8243;, scaleGridLeft=&#8221;7&#8243;, scaleGridRight=&#8221;106&#8243;); I use the above skinning method a lot and hence need to completely understand how to specify the co-ordinates to scale the graphic to any extent. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[66,42],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-flex","tag-flex","tag-scale-nine"],"_links":{"self":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33"}],"version-history":[{"count":0,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nayansavla.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}