※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


FORKED
  1. // forked from alumican_net's [Sample] BoundaryResizer Demo
  2. /**
  3.  * 目的が似たクラス(FViewBox)があったので便乗しますた。
  4.  * 描画目的なので出力がMatrixです。なので80行目あたりが主なあれです。
  5.  * ※このクラスはあまり最適化はされてないです。これだけじゃないけど…
  6.  * alumican.netさんに感謝。
  7.  */
  8. /**
  9.  * フォーク元:
  10.  * BoundaryResizerクラスを利用したリサイズ
  11.  * 
  12.  * このswfは下記URLで紹介している自作クラスのサンプルコードです
  13.  * @see http://blog.alumican.net/2009/10/07_225251
  14.  * 
  15.  * @author alumican.net<Yukiya Okuda>
  16.  */
  17. package
  18. {
  19.     import flash.display.Bitmap;
  20.     import flash.display.BitmapData;
  21.     import flash.display.Graphics;
  22.     import flash.display.Loader;
  23.     import flash.display.LoaderInfo;
  24.     import flash.display.PixelSnapping;
  25.     import flash.display.Sprite;
  26.     import flash.events.Event;
  27.     import flash.geom.Matrix;
  28.     import flash.geom.Rectangle;
  29.     import flash.net.URLRequest;
  30.     import com.bit101.components.Label;
  31.     import com.bit101.components.RadioButton;
  32.     import com.bit101.components.PushButton;
  33.     import flash.system.Security;
  34.     import frocessing.geom.FViewBox;
  35.     
  36.     [SWF(width = 465, height = 465, backgroundColor = 0xffffff, frameRate = 30)]
  37.     public class BoundaryResizerDemo extends Sprite
  38.     {
  39.         //----------------------------------------
  40.         //CLASS CONSTANTS
  41.         
  42.         private const W:uint = 465;
  43.         private const H:uint = 465;
  44.         
  45.         
  46.         
  47.         
  48.         
  49.         //----------------------------------------
  50.         //VARIABLES
  51.         
  52.         private var _picture:Bitmap;
  53.         private var _border:Sprite;
  54.         
  55.         private var viewbox:FViewBox;
  56.         
  57.         
  58.         
  59.         //----------------------------------------
  60.         //METHODS
  61.         
  62.         private function _resize():void
  63.         {            
  64.             //USE VIEW BOX
  65.             _picture.transform.matrix = viewbox.getTransformMatrix( _border.x, _border.y, _border.width, _border.height );
  66.         }
  67.         
  68.         public function BoundaryResizerDemo():void 
  69.         {
  70.             Security.loadPolicyFile("http://swf.wonderfl.net/crossdomain.xml");
  71.             
  72.             var vBmd:BitmapData, hBmd:BitmapData;
  73.             
  74.             _picture = addChild(new Bitmap()) as Bitmap;
  75.             var loader:Loader = new Loader();
  76.             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
  77.             {
  78.                 var bmd:BitmapData = new BitmapData(W, H, true, 0x00000000);
  79.                 bmd.draw(loader);
  80.                 var rect:Rectangle = bmd.getColorBoundsRect(0xffffffff, 0x00000000, false);
  81.                 var vb:FViewBox = new FViewBox( rect.x, rect.y, rect.width, rect.height );
  82.                 vb.scaleMode = FViewBox.SHOW_ALL;
  83.                 
  84.                 vBmd = new BitmapData(rect.width - 40, rect.height + 40true, 0xff80ff80);
  85.                 vBmd.draw(bmd, vb.getTransformMatrix(0,0,vBmd.width,vBmd.height), nullnullnulltrue);
  86.                 
  87.                 hBmd = new BitmapData(rect.width + 100, rect.height - 80true, 0xff80ff80);
  88.                 hBmd.draw(bmd, vb.getTransformMatrix(0,0,hBmd.width,hBmd.height), nullnullnulltrue);
  89.                 
  90.                 _picture.bitmapData = vBmd;
  91.                 _picture.smoothing = true;
  92.                 
  93.                 viewbox = new FViewBox( 00, vBmd.width, vBmd.height );
  94.                 
  95.                 e.target.removeEventListener(e.type, arguments.callee);
  96.                 loader = null;
  97.                 
  98.                 _resize();
  99.             } );
  100.             loader.load(new URLRequest("http://swf.wonderfl.net/static/assets/checkmate04/AmateurAssets.swf"));
  101.             
  102.             _border = addChild(new Sprite()) as Sprite;
  103.             var g:Graphics = _border.graphics;
  104.             g.lineStyle(2, 0xff0000);
  105.             g.drawRect(00290290);
  106.             _border.x = int((W - _border.width) / 2);
  107.             _border.y = 60;
  108.             
  109.             var title:Label = new Label(this0, -8"FViewBox Demo");
  110.             title.scaleX = title.scaleY = 2;
  111.             
  112.             new PushButton(this, W - 99 - 1019 * 0 + 10"Vertical Image"  , function():void { _picture.bitmapData = vBmd; _picture.smoothing = true; viewbox.width=vBmd.width; viewbox.height=vBmd.height; _resize(); } );
  113.             new PushButton(this, W - 99 - 1019 * 1 + 10"Horizontal Image"function():void { _picture.bitmapData = hBmd; _picture.smoothing = true; viewbox.width=hBmd.width; viewbox.height=hBmd.height; _resize(); } );
  114.             
  115.             var label0:Label = new Label(this10, H - 19 * 5 - 10"scaleMode : NO_SCALE");
  116.             new PushButton(this10, H - 19 * 4 - 10"EXACT_FIT"function():void { viewbox.scaleMode = FViewBox.EXACT_FIT; _resize(); label0.text = "scaleMode : EXACT_FIT"; } );
  117.             new PushButton(this10, H - 19 * 3 - 10"SHOW_ALL" , function():void { viewbox.scaleMode = FViewBox.SHOW_ALL;  _resize(); label0.text = "scaleMode : SHOW_ALL";  } );
  118.             new PushButton(this10, H - 19 * 2 - 10"NO_BORDER"function():void { viewbox.scaleMode = FViewBox.NO_BORDER; _resize(); label0.text = "scaleMode : NO_BORDER"; } );
  119.             new PushButton(this10, H - 19 * 1 - 10"NO_SCALE" , function():void { viewbox.scaleMode = FViewBox.NO_SCALE;  _resize(); label0.text = "scaleMode : NO_SCALE";  } );
  120.             
  121.             var label1:Label = new Label(this, W - 99 * 3 - 10, H - 19 * 4 - 10"align : CENTER");
  122.             new PushButton(this, W - 99 * 3 - 10, H - 19 * 3 - 10"TOP_LEFT"    , function():void { viewbox.align = FViewBox.TOP_LEFT;     _resize(); label1.text = "align : TOP_LEFT";     } );
  123.             new PushButton(this, W - 99 * 2 - 10, H - 19 * 3 - 10"TOP"         , function():void { viewbox.align = FViewBox.TOP;          _resize(); label1.text = "align : TOP";          } );
  124.             new PushButton(this, W - 99 * 1 - 10, H - 19 * 3 - 10"TOP_RIGHT"   , function():void { viewbox.align = FViewBox.TOP_RIGHT;    _resize(); label1.text = "align : TOP_RIGHT";    } );
  125.             new PushButton(this, W - 99 * 3 - 10, H - 19 * 2 - 10"LEFT"        , function():void { viewbox.align = FViewBox.LEFT;         _resize(); label1.text = "align : LEFT";         } );
  126.             new PushButton(this, W - 99 * 2 - 10, H - 19 * 2 - 10"CENTER"      , function():void { viewbox.align = FViewBox.CENTER;       _resize(); label1.text = "align : CENTER";       } );
  127.             new PushButton(this, W - 99 * 1 - 10, H - 19 * 2 - 10"RIGHT"       , function():void { viewbox.align = FViewBox.RIGHT;        _resize(); label1.text = "align : RIGHT";        } );
  128.             new PushButton(this, W - 99 * 3 - 10, H - 19 * 1 - 10"BOTTOM_LEFT" , function():void { viewbox.align = FViewBox.BOTTOM_LEFT;  _resize(); label1.text = "align : BOTTOM_LEFT";  } );
  129.             new PushButton(this, W - 99 * 2 - 10, H - 19 * 1 - 10"BOTTOM"      , function():void { viewbox.align = FViewBox.BOTTOM;       _resize(); label1.text = "align : BOTTOM";       } );
  130.             new PushButton(this, W - 99 * 1 - 10, H - 19 * 1 - 10"BOTTOM_RIGHT"function():void { viewbox.align = FViewBox.BOTTOM_RIGHT; _resize(); label1.text = "align : BOTTOM_RIGHT"; } );
  131.         }
  132.     }
  133. }
noswf
  1. // forked from alumican_net's [Sample] BoundaryResizer Demo
  2. /**
  3.  * BoundaryResizerクラスを利用したリサイズ
  4.  * 
  5.  * このswfは下記URLで紹介している自作クラスのサンプルコードです
  6.  * @see http://blog.alumican.net/2009/10/07_225251
  7.  * 
  8.  * @author alumican.net<Yukiya Okuda>
  9.  */
  10. package
  11. {
  12.     import flash.display.Bitmap;
  13.     import flash.display.BitmapData;
  14.     import flash.display.Graphics;
  15.     import flash.display.Loader;
  16.     import flash.display.LoaderInfo;
  17.     import flash.display.PixelSnapping;
  18.     import flash.display.Sprite;
  19.     import flash.events.Event;
  20.     import flash.geom.Matrix;
  21.     import flash.geom.Rectangle;
  22.     import flash.net.URLRequest;
  23.     import com.bit101.components.Label;
  24.     import com.bit101.components.RadioButton;
  25.     import com.bit101.components.PushButton;
  26.     import flash.system.Security;
  27.     
  28.     [SWF(width = 465, height = 465, backgroundColor = 0xffffff, frameRate = 30)]
  29.     public class BoundaryResizerDemo extends Sprite
  30.     {
  31.         //----------------------------------------
  32.         //CLASS CONSTANTS
  33.         
  34.         private const W:uint = 465;
  35.         private const H:uint = 465;
  36.         
  37.         
  38.         
  39.         
  40.         
  41.         //----------------------------------------
  42.         //VARIABLES
  43.         
  44.         private var _picture:Bitmap;
  45.         private var _border:Sprite;
  46.         
  47.         private var _scaleMode:String = BoundaryResizer.NO_SCALE;
  48.         private var _align:String     = BoundaryResizer.CENTER;
  49.         
  50.         
  51.         
  52.         
  53.         
  54.         //----------------------------------------
  55.         //METHODS
  56.         
  57.         private function _resize():void
  58.         {
  59.             var boundary:Rectangle = _border.getRect(this);
  60.             var target:Rectangle   = _picture.bitmapData.rect;
  61.             
  62.             //IMPORTANT HERE--------------------------
  63.             var resized:Rectangle = BoundaryResizer.resize(target, boundary, _scaleMode, _align);
  64.             //----------------------------------------
  65.             
  66.             _picture.x      = resized.x;
  67.             _picture.y      = resized.y;
  68.             _picture.width  = resized.width;
  69.             _picture.height = resized.height;
  70.         }
  71.         
  72.         public function BoundaryResizerDemo():void 
  73.         {
  74.             Security.loadPolicyFile("http://swf.wonderfl.net/crossdomain.xml");
  75.             
  76.             _picture = addChild(new Bitmap()) as Bitmap;
  77.             var loader:Loader = new Loader();
  78.             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
  79.             {
  80.                 var bmd:BitmapData = new BitmapData(W, H, true, 0x00000000);
  81.                 bmd.draw(loader);
  82.                 var rect:Rectangle = bmd.getColorBoundsRect(0xffffffff, 0x00000000, false);
  83.                 var trim:BitmapData = new BitmapData(rect.width, rect.height + 20true, 0xff80ff80);
  84.                 trim.draw(bmd, new Matrix(1001, -rect.x, -rect.y + 10));
  85.                 _picture.bitmapData = trim;
  86.                 _picture.smoothing = true;
  87.                 
  88.                 e.target.removeEventListener(e.type, arguments.callee);
  89.                 loader = null;
  90.                 
  91.                 _resize();
  92.             } );
  93.             loader.load(new URLRequest("http://swf.wonderfl.net/static/assets/checkmate04/AmateurAssets.swf"));
  94.             
  95.             _border = addChild(new Sprite()) as Sprite;
  96.             var g:Graphics = _border.graphics;
  97.             g.lineStyle(2, 0xff0000);
  98.             g.drawRect(00290290);
  99.             _border.x = int((W - _border.width) / 2);
  100.             _border.y = 50;
  101.             
  102.             var title:Label = new Label(this0, -8"BoundaryResizer Demo");
  103.             title.scaleX = title.scaleY = 2;
  104.             
  105.             var label0:Label = new Label(this10, H - 19 * 5 - 10"scaleMode : NO_SCALE");
  106.             new PushButton(this10, H - 19 * 4 - 10"EXACT_FIT"function():void { _scaleMode = BoundaryResizer.EXACT_FIT; _resize(); label0.text = "scaleMode : EXACT_FIT"; } );
  107.             new PushButton(this10, H - 19 * 3 - 10"SHOW_ALL" , function():void { _scaleMode = BoundaryResizer.SHOW_ALL;  _resize(); label0.text = "scaleMode : SHOW_ALL";  } );
  108.             new PushButton(this10, H - 19 * 2 - 10"NO_BORDER"function():void { _scaleMode = BoundaryResizer.NO_BORDER; _resize(); label0.text = "scaleMode : NO_BORDER"; } );
  109.             new PushButton(this10, H - 19 * 1 - 10"NO_SCALE" , function():void { _scaleMode = BoundaryResizer.NO_SCALE;  _resize(); label0.text = "scaleMode : NO_SCALE";  } );
  110.             
  111.             var label1:Label = new Label(this, W - 99 * 3 - 10, H - 19 * 4 - 10"align : CENTER");
  112.             new PushButton(this, W - 99 * 3 - 10, H - 19 * 3 - 10"TOP_LEFT"    , function():void { _align = BoundaryResizer.TOP_LEFT;     _resize(); label1.text = "align : TOP_LEFT";     } );
  113.             new PushButton(this, W - 99 * 2 - 10, H - 19 * 3 - 10"TOP"         , function():void { _align = BoundaryResizer.TOP;          _resize(); label1.text = "align : TOP";          } );
  114.             new PushButton(this, W - 99 * 1 - 10, H - 19 * 3 - 10"TOP_RIGHT"   , function():void { _align = BoundaryResizer.TOP_RIGHT;    _resize(); label1.text = "align : TOP_RIGHT";    } );
  115.             new PushButton(this, W - 99 * 3 - 10, H - 19 * 2 - 10"LEFT"        , function():void { _align = BoundaryResizer.LEFT;         _resize(); label1.text = "align : LEFT";         } );
  116.             new PushButton(this, W - 99 * 2 - 10, H - 19 * 2 - 10"CENTER"      , function():void { _align = BoundaryResizer.CENTER;       _resize(); label1.text = "align : CENTER";       } );
  117.             new PushButton(this, W - 99 * 1 - 10, H - 19 * 2 - 10"RIGHT"       , function():void { _align = BoundaryResizer.RIGHT;        _resize(); label1.text = "align : RIGHT";        } );
  118.             new PushButton(this, W - 99 * 3 - 10, H - 19 * 1 - 10"BOTTOM_LEFT" , function():void { _align = BoundaryResizer.BOTTOM_LEFT;  _resize(); label1.text = "align : BOTTOM_LEFT";  } );
  119.             new PushButton(this, W - 99 * 2 - 10, H - 19 * 1 - 10"BOTTOM"      , function():void { _align = BoundaryResizer.BOTTOM;       _resize(); label1.text = "align : BOTTOM";       } );
  120.             new PushButton(this, W - 99 * 1 - 10, H - 19 * 1 - 10"BOTTOM_RIGHT"function():void { _align = BoundaryResizer.BOTTOM_RIGHT; _resize(); label1.text = "align : BOTTOM_RIGHT"; } );
  121.             
  122.             //\(^o^)/
  123.             //RadioButton.as : Currently only one group can be created.
  124.             /*
  125.             var scaleModeGroup:Sprite = addChild(new Sprite()) as Sprite;
  126.             scaleModeGroup.x = 10;
  127.             scaleModeGroup.y = H - 16 * 5 - 10;
  128.             new Label(scaleModeGroup, 0, 0, "scaleMode");
  129.             new RadioButton(scaleModeGroup, 0, 16 * 1 + 5, "EXACT_FIT", false, function():void { _scaleMode = BoundaryResizer.EXACT_FIT; _resize(); } );
  130.             new RadioButton(scaleModeGroup, 0, 16 * 2 + 5, "SHOW_ALL" , false, function():void { _scaleMode = BoundaryResizer.SHOW_ALL;  _resize(); } );
  131.             new RadioButton(scaleModeGroup, 0, 16 * 3 + 5, "NO_BORDER", false, function():void { _scaleMode = BoundaryResizer.NO_BORDER; _resize(); } );
  132.             new RadioButton(scaleModeGroup, 0, 16 * 4 + 5, "NO_SCALE" , true , function():void { _scaleMode = BoundaryResizer.NO_SCALE;  _resize(); } );
  133.             
  134.             var alignGroup:Sprite = addChild(new Sprite()) as Sprite;
  135.             alignGroup.x = W - 80 * 3 - 10;
  136.             alignGroup.y = H - 16 * 4 - 10;
  137.             new Label(alignGroup, 0, 0, "align");
  138.             new RadioButton(alignGroup, 80 * 0, 16 * 1 + 5, "TOP_LEFT"    , false, function():void { _align = BoundaryResizer.TOP_LEFT;     _resize(); } );
  139.             new RadioButton(alignGroup, 80 * 1, 16 * 1 + 5, "TOP"         , false, function():void { _align = BoundaryResizer.TOP;          _resize(); } );
  140.             new RadioButton(alignGroup, 80 * 2, 16 * 1 + 5, "TOP_RIGHT"   , false, function():void { _align = BoundaryResizer.TOP_RIGHT;    _resize(); } );
  141.             new RadioButton(alignGroup, 80 * 0, 16 * 2 + 5, "LEFT"        , false, function():void { _align = BoundaryResizer.LEFT;         _resize(); } );
  142.             new RadioButton(alignGroup, 80 * 1, 16 * 2 + 5, "CENTER"      , true , function():void { _align = BoundaryResizer.CENTER;       _resize(); } );
  143.             new RadioButton(alignGroup, 80 * 2, 16 * 2 + 5, "RIGHT"       , false, function():void { _align = BoundaryResizer.RIGHT;        _resize(); } );
  144.             new RadioButton(alignGroup, 80 * 0, 16 * 3 + 5, "BOTTOM_LEFT" , false, function():void { _align = BoundaryResizer.BOTTOM_LEFT;  _resize(); } );
  145.             new RadioButton(alignGroup, 80 * 1, 16 * 3 + 5, "BOTTOM"      , false, function():void { _align = BoundaryResizer.BOTTOM;       _resize(); } );
  146.             new RadioButton(alignGroup, 80 * 2, 16 * 3 + 5, "BOTTOM_RIGHT", false, function():void { _align = BoundaryResizer.BOTTOM_RIGHT; _resize(); } );
  147.             */
  148.         }
  149.     }
  150. }
  151. import flash.display.StageAlign;
  152. import flash.display.StageScaleMode;
  153. import flash.geom.Rectangle;
  154. /**
  155.  * BoundaryResizer
  156.  * 様々なリサイズをRectangleベースで実行するクラスです.
  157.  * @see http://blog.alumican.net/2009/10/07_225251
  158.  * @author alumican.net<Yukiya Okuda>
  159.  */
  160. internal class BoundaryResizer
  161. {
  162.     //-------------------------------------
  163.     //CLASS CONSTANTS
  164.     
  165.     /**
  166.      * scaleMode
  167.      * リサイズ方法を操作するscaleModeには以下の定数を指定できます.
  168.      */
  169.     static public const EXACT_FIT:String = StageScaleMode.EXACT_FIT; // targetとboundaryが完全に一致するようにリサイズされます.多くの場合,targetの縦横比は保たれません.
  170.     static public const SHOW_ALL:String  = StageScaleMode.SHOW_ALL;  // targetが縦横比を保ち,かつtargetがboundaryの内側にフィットするようにリサイズされます.targetがトリミングされることはありませんが,上下または左右に隙間ができることがあります.
  171.     static public const NO_BORDER:String = StageScaleMode.NO_BORDER; // targetが縦横比を保ち,かつboundaryがtargetの内側にフィットするようにリサイズされます.targetとboundaryの間に隙間ができることはありませんが,targetがトリミングされることがあります.
  172.     static public const NO_SCALE:String  = StageScaleMode.NO_SCALE;  // リサイズがおこなわれず,alignによる基準点合わせのみがおこなわれます.
  173.     
  174.     /**
  175.      * align
  176.      * リサイズ後のオブジェクトの基準点を操作するalignには以下の定数を指定できます.
  177.      */
  178.     static public const TOP_LEFT:String     = StageAlign.TOP_LEFT;     // x軸方向:左  , y軸方向:上
  179.     static public const TOP:String          = StageAlign.TOP;          // x軸方向:中央, y軸方向:上
  180.     static public const TOP_RIGHT:String    = StageAlign.TOP_RIGHT;    // x軸方向:右  , y軸方向:上
  181.     static public const LEFT:String         = StageAlign.LEFT;         // x軸方向:左  , y軸方向:中央
  182.     static public const CENTER:String       = "";                      // x軸方向:中央, y軸方向:中央
  183.     static public const RIGHT:String        = StageAlign.RIGHT;        // x軸方向:右  , y軸方向:中央
  184.     static public const BOTTOM_LEFT:String  = StageAlign.BOTTOM_LEFT;  // x軸方向:左  , y軸方向:下
  185.     static public const BOTTOM:String       = StageAlign.BOTTOM;       // x軸方向:中央, y軸方向:下
  186.     static public const BOTTOM_RIGHT:String = StageAlign.BOTTOM_RIGHT; // x軸方向:右  , y軸方向:下
  187.     
  188.     
  189.     
  190.     
  191.     
  192.     //-------------------------------------
  193.     //METHODS
  194.     
  195.     /**
  196.      * targetをboundaryに合わせてリサイズした矩形を返します.
  197.      * リサイズ方法と基準点をscaleMode,alignで指定できます.
  198.      * @param   target    リサイズ対象オブジェクトの矩形を指定します.(例)リサイズしたい画像の矩形
  199.      * @param   boundary  リサイズの基準となる矩形を指定します.(例)リサイズ後の画像を収める枠
  200.      * @param   scaleMode リサイズ時のスケールモードを指定します.このパラメータはStageScaleModeと互換性があります.このパラメータを省略した場合はBoundaryResizer.NO_SCALEとなり,リサイズはおこなわれません.
  201.      * @param   align     boundaryに対するtargetの基準位置を指定します.このパラメータはStageAlignと互換性があります.このパラメータを省略した場合はBoundaryResizer.CENTERとなり,縦横ともに中央揃えとなります.
  202.      * @return            リサイズ後の矩形が返されます.target及びboundaryは変更しません.
  203.      */
  204.     static public function resize(target:Rectangle, boundary:Rectangle, scaleMode:String = "noScale", align:String = ""):Rectangle
  205.     {
  206.         var tx:Number = target.x,
  207.             ty:Number = target.y,
  208.             tw:Number = target.width,
  209.             th:Number = target.height,
  210.             bx:Number = boundary.x,
  211.             by:Number = boundary.y,
  212.             bw:Number = boundary.width,
  213.             bh:Number = boundary.height,
  214.             rx:Number,
  215.             ry:Number,
  216.             rw:Number,
  217.             rh:Number;
  218.         
  219.         switch (scaleMode)
  220.         {
  221.             case SHOW_ALL:
  222.             case NO_BORDER:
  223.                 var ratioW:Number = bw / tw,
  224.                     ratioH:Number = bh / th,
  225.                     ratio:Number  = (scaleMode == SHOW_ALL) ? ( (ratioW < ratioH) ? ratioW : ratioH ) : 
  226.                                                               ( (ratioW > ratioH) ? ratioW : ratioH ) ;
  227.                 rw = ratio * tw;
  228.                 rh = ratio * th;
  229.                 break;
  230.             
  231.             case EXACT_FIT:
  232.                 return new Rectangle(bx, by, bw, bh);
  233.             
  234.             default:
  235.                 rw = tw;
  236.                 rh = th;
  237.                 break;
  238.         }
  239.         
  240.         rx = bx + ( (align == TOP_LEFT    || align == LEFT   || align == BOTTOM_LEFT ) ? 0               :
  241.                     (align == TOP_RIGHT   || align == RIGHT  || align == BOTTOM_RIGHT) ? (bw - rw)       :
  242.                                                                                          (bw - rw) / 2 ) ;
  243.         ry = by + ( (align == TOP_LEFT    || align == TOP    || align == TOP_RIGHT   ) ? 0               :
  244.                     (align == BOTTOM_LEFT || align == BOTTOM || align == BOTTOM_RIGHT) ? (bh - rh)       :
  245.                                                                                          (bh - rh) / 2 ) ;
  246.         
  247.         return new Rectangle(rx, ry, rw, rh);
  248.     }
  249. }
noswf
Get Adobe Flash Player