うぇー

by zahir
scale9Gridが動かないどうしたらいいんだろうw
*
* WinXP SP3 
* FP 10.0.32.18
* sdk 3.4.x
*
♥0 | Line 54 | Modified 2009-09-15 23:18:55 | MIT License
play

ActionScript3 source code

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

/* 
 * scale9Gridが動かないどうしたらいいんだろうw
 *
 * WinXP SP3 
 * FP 10.0.32.18
 * sdk 3.4.x
 *
 */
package{
	import flash.display.*;
	import flash.events.Event;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	
	[SWF(width = 465, height = 465, backgroundColor = 0xCCCCCC)]

	public class Scale9_test extends Sprite{
		private var o:Sprite;
		private var rect:Shape;
		private var _scale:Number = 1.01;
		
		private var m:Matrix;
		
		public function Scale9_test(){
			var w:int = 100;
			var h:int = 100;
			scaleX = scaleY = 1;
			o = new Sprite();
			this.addChild( o );
			var s:Shape = new Shape();
			o.addChild( s );
			rect = new Shape();
			o.addChild( rect );
			
			var g:Graphics = s.graphics;
			m = new Matrix();
			m.createGradientBox( w, h, 0.017453 * 90);
			g.lineStyle( 2 );
			g.lineGradientStyle("linear", [0x999999, 0x666666], [1,1] , [0, 255], m);
			g.beginGradientFill( "linear", [0x333333, 0x111111], [1,1] , [0, 255], m);
			g.drawRoundRect( 0,0, w, h, 16,16);
			g.endFill();
			
			g = rect.graphics;
			g.lineStyle( 1 , 0x000066);
			g.beginGradientFill( "linear", [0x0099FF, 0x0066CC], [1,1] , [0, 255], m);
			g.drawRect( 16,16, w-32, h-32);
			g.endFill();
			
			o.scale9Grid = new Rectangle( 16, 16, w-16, h-16 );
			
			rePos();
			
			this.addEventListener(Event.ENTER_FRAME, onEnter);
		}
		private function onEnter(e:Event):void{
			o.scaleX *= _scale;
			if( o.scaleX >= 2.0){
				_scale = 0.99;
			}
			if( o.scaleX <= 1.0){
				_scale = 1.01;
			}
			
			rePos();
		}
		private function rePos():void{
			o.x = (stage.stageWidth - o.width) >>1;
			o.y = (stage.stageHeight - o.height) >>1;
		}
	}
}

Forked