forked from: flash on 2009-8-12

by yooKo_old_account forked from flash on 2009-8-12 (diff: 123)
製作者
* yooko a.k.a (考え中) 
* 
* 自作サイト『SELFLASH』
* http://selflash.jp
* ブログ
* http://selflash.jp/blog * 
* 
* 
* 
♥0 | Line 86 | Modified 2009-08-13 05:26:02 | MIT License
play

ActionScript3 source code

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

// forked from yooKo's flash on 2009-8-12
/* 
 * 
 * 製作者
 * yooko a.k.a (考え中) 
 * 
 * 自作サイト『SELFLASH』
 * http://selflash.jp
 * ブログ
 * http://selflash.jp/blog * 
 * 
 * 
 * 
 */

package 
{
    import net.hires.debug.Stats;
	import flash.display.Graphics;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.events.*;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import caurina.transitions.Tweener;
	
    public class FlashTest extends Sprite 
	{		
		// タイマー
		private var _timer:Timer;
		// スイッチ
		private var _swich:int = 0;	
		
		private var _text:TextField;
		// ステージ上のマウスの座標
		private var _mouseX:Number;
		private var _mouseY:Number;
		// ステージ上のマウスの移動幅
		private var _Xidouhaba:Number;
		private var _Yidouhaba:Number;
		// マウスのxの移動幅とyの移動幅の差
		private var _kekka:Number;
		// 円
		private var _circle:Shape;
		
        public function FlashTest() 
		{
			//addChild(new Stats());
			
			// 円を描画する
			_circle = new Shape();
			_circle.x = stage.stageWidth / 2;
			_circle.y = stage.stageHeight / 2;
			var _g:Graphics = _circle.graphics;
			_g.clear();
			_g.beginFill( 0x001133 );
			_g.drawCircle(0,0, 50);
			_g.endFill();
			addChild(_circle);
			
			// タイマーの設定
			_timer = new Timer(50);			
			_timer.addEventListener(TimerEvent.TIMER, _onKeisoku);
			
			/* _swichの状況を画面に表示する時にコメントアウトする
			 * 
			 */
			//_text = new TextField();
			//_text.text = "始まるよ";
			//_text.y = stage.stageHeight / 2;
			//_text.height = _text.textHeight + 100;
			//_text.width = _text.textWidth + 100;
			//addChild(_text);
			
			// タイマーの開始
			_timer.start();           
        }
		
		private function _onKeisoku(e:TimerEvent = null):void
		{	
			/*_swichの状況を画面に表示する時にコメントアウトする
			 * 
			 */
			//_text.appendText( "\nスイッチは" + _swich);
			//_text.height = _text.textHeight + 20;
			//_text.width = _text.textWidth + 20;
			//_text.y -= 15;					
			
			// 前回のマウスの位置と今回のマウスの位置の差を計算する
			_Xidouhaba = stage.mouseX - _mouseX;
			_Yidouhaba = stage.mouseY - _mouseY;
			
			// stage上のマウスの位置を調べて_iXにとっておく
			_mouseX = stage.mouseX;
			_mouseY = stage.mouseY;
			
			// xの移動幅とyの移動幅の差を計算する
			_kekka = Math.abs(_Xidouhaba) - Math.abs(_Yidouhaba);
			
			switch( _swich )
			{
				case 0:
				if ( _Xidouhaba > 50 )
				{
					if ( - 20 < _kekka && 20 > _kekka  )
					{
						_swich = 1;
					};
				};
				break;
				
				case 1:
				if ( _Yidouhaba > 50 )
				{
					if ( -30 < _kekka && 30 > _kekka )
					{
						_swich = 2;
					}else
					{
						_swich = 0;
					};
				}else
				{
					_swich = 0;
				}
				break;
				
				case 2:
				if ( _Xidouhaba > - 80 )
				{
					_swich = 3;
				}
				break;
				
				case 3:
				Tweener.addTween(_circle, { x:Math.random() * stage.stageWidth, y:Math.random() * stage.stageHeight, time:0.5, transition:"easeOutElastic" } );
				_circle.x = Math.random() * stage.stageWidth;
				_circle.y = Math.random() * stage.stageHeight;	
				_swich = 0;
				break;
				
				
			}
			//switch( _swich )
			//{
				// マウスで描かれる円がyの移動から開始した時とxの移動から開始した場合で条件分岐させる
				//case 0:
				// yの移動から始まった時は 1 とする
				//if ( 0 > _kekka )
				//{
					//_swich = 1;
				//}
				// xの移動から始まった時は 5 とする
				//else if ( 0 < _kekka )
				//{
					//_swich = 5;
				//}
				//break;
				//
				//case 1:
				//if ( 0 < _kekka )
				//{
					//_swich = 2;
				//}else
				//{
					//_swich = 0;
				//}
				//break;
				//
				//case 2:
				//if ( 0 > _kekka )
				//{
					//_swich = 3;
				//}else
				//{
					//_swich = 0;
				//}
				//break;
				//
				//case 3:
				//if ( 0 < _kekka )
				//{
					//_swich = 4;
				//}else
				//{
					//_swich = 0;
				//}
				//break;
				//
				//case 4:
				// マウスによる円の動きが完了した時の処理
				//_text.appendText("\nイベント開始!その1");
				//Tweener.addTween(_circle, { x:Math.random() * stage.stageWidth, y:Math.random() * stage.stageHeight, time:0.5, transition:"easeOutElastic" } );
				//_circle.x = Math.random() * stage.stageWidth;
				//_circle.y = Math.random() * stage.stageHeight;	
				// 処理が終わったらスイッチを 0 に戻す
				//_swich = 0;
				//break;				
				//
				//case 5:
				//if ( 0 > _kekka )
				//{
					//_swich = 6;
				//}else
				//{
					//_swich = 0;
				//}
				//break;
				//
				//case 6:
				//if ( 0 < _kekka )
				//{
					//_swich = 7;
				//}else
				//{
					//_swich = 0;
				//}
				//break;
				//
				//case 7:
				//if ( 0 > _kekka )
				//{
					//_swich = 8;
				//}else
				//{
					//_swich = 0;
				//}
				//break;
				//
				//case 8:
				// マウスによる円の動きが完了した時の処理
				//_text.appendText("\nイベント開始!その2");
				//Tweener.addTween(_circle, { x:Math.random() * stage.stageWidth, y:Math.random() * stage.stageHeight, time:0.5, transition:"easeOutElastic" } );				
				//_circle.x = Math.random() * stage.stageWidth;
				//_circle.y = Math.random() * stage.stageHeight;
				// 処理が終わったらスイッチを 0 に戻す
				//_swich = 0;
				//break;
				//
			//}			
		}
    }
}

Forked