forked from: ボーダーずれずれ

by AtuyL forked from ボーダーずれずれ (diff: 30)
SWF範囲を見えるように
♥0 | Line 25 | Modified 2010-09-09 11:01:01 | MIT License
play

ActionScript3 source code

/**
 * Copyright AtuyL ( http://wonderfl.net/user/AtuyL )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iaMK
 */

// forked from katapad's ボーダーずれずれ
package {
    import flash.display.*;
    [SWF(backgroundColor=0xFF9900)]//SWF範囲を見えるように
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
            var border_RED:Shape = new Shape();
            border_RED.graphics.lineStyle(2, 0xFF0000, 1, false, LineScaleMode.NORMAL);
            border_RED.graphics.drawRect( 0, 0, 100, 100);
            
            var border_BLUE:Shape = new Shape();
            border_BLUE.graphics.lineStyle(2, 0x0000FF, 1, false, LineScaleMode.NONE);
            border_BLUE.graphics.drawRect( 0, 0, 100, 100);
            
            var rect : Shape = new Shape();
            rect.graphics.beginFill(0, 0.9);
            rect.graphics.drawRect( 0, 0, 100, 100);
            rect.graphics.endFill();
            
            addChild(rect);
            addChild(border_RED);
            addChild(border_BLUE);
            
            border_RED.x = border_BLUE.x = rect.x = 10.0;
            border_RED.y = border_BLUE.y = rect.y = 10.0;
            //border_RED.scaleX = border_BLUE.scaleX = rect.scaleX = 4.0;
            //border_RED.scaleY = border_BLUE.scaleY = rect.scaleY = 4.0;
            border_RED.width = border_BLUE.width = rect.width = 400;
            border_RED.height = border_BLUE.height = rect.height = 400;
            
            /**
             * LineScaleMode.NORMALで描画後の矩形領域を基準に、
             * 幅と高さが指定に沿うよう座標位置を移動させてるっぽい。
             * 
             * 回避策:width,height ではなく scaleX,scaleY を使う
             */
        }
    }
}