forked from: forked from: flash on 2009-8-12
forked from forked from: flash on 2009-8-12 (diff: 171)
製作者 * yooko a.k.a (考え中) * * 自作サイト『SELFLASH』 * http://selflash.jp * ブログ * http://selflash.jp/blog * * * *
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/bS5w
*/
// forked from yooKo's forked from: flash on 2009-8-12
// forked from yooKo's flash on 2009-8-12
/*
*
* 製作者
* yooko a.k.a (考え中)
*
* 自作サイト『SELFLASH』
* http://selflash.jp
* ブログ
* http://selflash.jp/blog *
*
*
*
*/
package
{
import flash.display.GradientType;
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 _triangle_timer:Timer;
private var _circle_timer:Timer;
// スイッチ
private var _triangle_swich:int = 0;
private var _circle_swich:int = 0;
private var _text:TextField;
// ステージ上のマウスの座標
private var _mouseX:Number;
private var _mouseY:Number;
private var _mouseX2:Number;
private var _mouseY2:Number;
// ステージ上のマウスの移動幅
private var _Xidouhaba:Number;
private var _Yidouhaba:Number;
private var _Xidouhaba2:Number;
private var _Yidouhaba2:Number;
// マウスのxの移動幅とyの移動幅の差
private var _kekka_triangle:Number;
private var _kekka_circle:Number;
// 円
private var _circle:Shape;
// 三角形
private var _triangle:Shape;
// 三角形の設定
private var _tx:int = 150;
private var _ty:int = 50;
private var _tw:int = 100;
private var _th:int = 150;
public function FlashTest()
{
// 円を描画する
_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);
// 三角形を描写する
_triangle = new Shape();
var _tg:Graphics = _triangle.graphics;
_tg.beginFill(0x000000);
_tg.moveTo(_tx, _ty);
_tg.lineTo(_tx + _tw / 2, _th);
_tg.lineTo(_tx - _tw / 2, _th);
_tg.endFill();
addChild(_triangle);
// タイマーの設定
_triangle_timer = new Timer(150);
_triangle_timer.addEventListener(TimerEvent.TIMER, _onTriangle);
_circle_timer = new Timer(50);
_circle_timer.addEventListener(TimerEvent.TIMER, _onCircle);
/* _swichの状況を画面に表示する時にコメントアウトする
*
*/
//_text = new TextField();
//_text.text = "始まるよ";
//_text.y = stage.stageHeight / 2;
//_text.height = _text.textHeight + 100;
//_text.width = _text.textWidth + 100;
//addChild(_text);
// タイマーの開始
_circle_timer.start();
_triangle_timer.start();
}
private function _onTriangle(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);
_kekka_triangle = _Xidouhaba / _Yidouhaba;
switch( _triangle_swich )
{
case 0:
if ( _Xidouhaba > 40 && _Yidouhaba < - 50)
{
if ( _kekka_triangle < 0 )
{
_triangle_swich = 1;
};
};
break;
case 1:
if ( _Yidouhaba > 40 && _Xidouhaba > 40 )
{
if ( _kekka_triangle > 0 )
{
_triangle_swich = 2;
}else
{
_triangle_swich = 0;
};
}else
{
_triangle_swich = 0;
}
break;
case 2:
if ( _Xidouhaba < - 30 && -50 < _Yidouhaba < 50 )
{
_triangle_swich = 3;
}else
{
_triangle_swich = 0;
}
break;
case 3:
//_text.appendText("\nイベント開始!その1");
Tweener.addTween(_triangle, { x:Math.random() * stage.stageWidth, y:Math.random() * stage.stageHeight, time:0.5, transition:"easeOutElastic" } );
_triangle_swich = 0;
break;
}
}
private function _onCircle(e:TimerEvent = null):void
{
// 前回のマウスの位置と今回のマウスの位置の差を計算する
_Xidouhaba2 = stage.mouseX - _mouseX2;
_Yidouhaba2 = stage.mouseY - _mouseY2;
// stage上のマウスの位置を調べて_iXにとっておく
_mouseX2 = stage.mouseX;
_mouseY2 = stage.mouseY;
// xの移動幅とyの移動幅の差を計算する
_kekka_circle = Math.abs(_Xidouhaba2) - Math.abs(_Yidouhaba2);
//_kekka_triangle = _Xidouhaba / _Yidouhaba;
switch( _circle_swich )
{
//マウスで描かれる円がyの移動から開始した時とxの移動から開始した場合で条件分岐させる
case 0:
//yの移動から始まった時は 1 とする
if ( 0 > _kekka_circle )
{
_circle_swich = 1;
}
//xの移動から始まった時は 5 とする
else if ( 0 < _kekka_circle )
{
_circle_swich = 5;
}
break;
case 1:
if ( 0 < _kekka_circle )
{
_circle_swich = 2;
}else
{
_circle_swich = 0;
}
break;
case 2:
if ( 0 > _kekka_circle )
{
_circle_swich = 3;
}else
{
_circle_swich = 0;
}
break;
case 3:
if ( 0 < _kekka_circle )
{
_circle_swich = 4;
}else
{
_circle_swich = 0;
}
break;
case 4:
//マウスによる円の動きが完了した時の処理
//_text.appendText("\nイベント開始!その1");
Tweener.addTween(_circle, { x:Math.random(), y:Math.random(), time:0.5, transition:"easeOutElastic" } );
//処理が終わったらスイッチを 0 に戻す
_circle_swich = 0;
break;
case 5:
if ( 0 > _kekka_circle )
{
_circle_swich = 6;
}else
{
_circle_swich = 0;
}
break;
case 6:
if ( 0 < _kekka_circle )
{
_circle_swich = 7;
}else
{
_circle_swich = 0;
}
break;
case 7:
if ( 0 > _kekka_circle )
{
_circle_swich = 8;
}else
{
_circle_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" } );
//処理が終わったらスイッチを 0 に戻す
_circle_swich = 0;
break;
}
}
}
}
