ボタン君
すいません。コード汚いですね…
/**
* Copyright Tamanegi_kenshi ( http://wonderfl.net/user/Tamanegi_kenshi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/9j1y
*/
// forked from Event's Button
//すいません。コード汚いですね…
package {
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.*;
[SWF(backgroundColor = 0x000000)]
public class FlashTest extends Sprite {
private var ball:Ball;
private var fuki:Fuki;
private var fuki2:Fuki2;
private var fuki3:Fuki3;
private var ballNum:int = 3;
private var ballArr:Array = [];
private var ballX:int = 232;
private var ballY:int = 232;
private var bt:Bitmap;
private var bd:BitmapData
private var isStart:Boolean = true;
private var isStop:Boolean = false;
private var hansei:int = 400;
private var stopNum:int = 0;
public function FlashTest() {
init();
}
private function init():void{
ball = new Ball();
fuki = new Fuki();
fuki2 = new Fuki2();
fuki3 = new Fuki3();
addChild(fuki);
addChild(fuki2);
addChild(fuki3);
fuki2.visible = false;
fuki3.visible = false;
stage.addChild(ball)
ball.x = ballX;
ball.y = ballY;
//ball.buttonMode = true;
ball.addEventListener(Event.ENTER_FRAME, onEnter);
ball.addEventListener(MouseEvent.CLICK, onClick);
}//init
private function onClick(e:MouseEvent):void{
ball.x = Math.random() * 400 + 30;
ball.y = Math.random() * 400 + 30;
isStop = false;
isStart = true;
fuki2.visible = false;
stopNum = -1;
fuki3.visible = true;
fuki3.x = ball.x - 25;
fuki3.y = ball.y - 30;
hansei = 250;
}
private function onEnter(e:Event):void{
if(isStart == true){
hansei--;
var fx:Number = (ball.x - fuki.x) * 0.5;
var fy:Number = (ball.y - fuki.y) * 0.5;
fuki.x += fx;
fuki.y += fy;
var fx2:Number = (ball.x - fuki2.x) * 0.5;
var fy2:Number = (ball.y - fuki2.y) * 0.5;
fuki2.x += fx;
fuki2.y += fy;
var fx4:Number = (ball.x - 25 - fuki3.x) * 0.5;
var fy4:Number = (ball.y - 30 - fuki3.y) * 0.5;
fuki3.x += fx4;
fuki3.y += fy4;
var dx:Number = ball.x - mouseX;
var dy:Number = ball.y - mouseY;
var rad:Number = Math.atan2(dy, dx);
var dist:Number = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
var per:Number = 1000 / dist;
ball.x += per * Math.cos(rad) + (ballX - ball.x) * 0.05;
ball.y += per * Math.sin(rad) + (ballY - ball.y) * 0.05;
if(ball.x < 0){
ball.x = 465;
stopNum++;
}else if(ball.x > 465){
ball.x = 0;
stopNum++;
}
if(ball.y < 0){
ball.y = 465;
stopNum++;
}else if(ball.y > 465){
ball.y = 0;
stopNum++;
}
}
if(hansei < 0 || stopNum > 5){
isStart = false;
isStop = true;
}
if(isStop == true){
fuki.visible = false;
fuki2.visible = true;
fuki3.visible = false;
var vx:Number = (232 - ball.x) * 0.1;
var vy:Number = (232 - ball.y) * 0.1;
ball.x += vx;
ball.y += vy;
var fx3:Number = (ball.x - 35 - fuki2.x) * 0.5;
var fy3:Number = (ball.y - 30 -fuki2.y) * 0.5;
fuki2.x += fx3;
fuki2.y += fy3;
}
}
}
}
import flash.display.BitmapData;
import flash.filters.GlowFilter;
import flash.filters.BlurFilter;
import flash.events.Event;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.text.TextField;
class Ball extends Sprite{
public function Ball(){
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xffff00);
sp.graphics.drawCircle(0, 0, 5);
sp.graphics.endFill();
addChild(sp);
sp.buttonMode = true;
sp.filters = [new BlurFilter(4, 4, 1), new GlowFilter(0xffffff, 1, 10, 10)];
}
public function setFuki():void{
var fuki:Fuki = new Fuki();
addChild(fuki);
fuki.x = -30;
fuki.y = -30;
fuki.mouseEnabled = false;
}
}
import flash.filters.GlowFilter;
import flash.filters.BlurFilter;
import flash.events.Event;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.text.TextField;
class Fuki extends Sprite{
private var num:int = 0;
private var textArr:Array = ["こっち、\nこっち~",
"鬼さんこちら~",
"おっと!!\n危ね~",
"・・・・・・",
"疲れてきた~",
"疲れてきた~",
];
private var tf:TextField;
private var tfW:Number = 0;
public function Fuki(){
var sp:Sprite = new Sprite();
tf= new TextField();
tf.text = "押せるもんなら\n押してみろ~";
//tf.autoSize = "middle";
tf.textColor = 0xffffff;
tf.x = 0;
tf.y = -10;
sp.graphics.beginFill(0xffffff);
sp.graphics.drawEllipse(0, 0, 0, 20);
sp.graphics.endFill();
addChild(sp);
sp.buttonMode = false;
sp.mouseEnabled = false;
sp.addChild(tf);
sp.filters= [ new GlowFilter(0xffffff, 1, 10, 10)];
var my_timer:Timer = new Timer(2000);
my_timer.addEventListener(TimerEvent.TIMER, onTimer);
my_timer.start();
}
private function onTimer(e:TimerEvent):void{
tf.text = textArr[num];
num++
if(num > textArr.length - 1){
num = 0;
}
}
}
import flash.filters.GlowFilter;
import flash.filters.BlurFilter;
import flash.events.Event;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.text.TextField;
class Fuki2 extends Sprite{
public var num:int = 0;
private var textArr:Array = ["お願いです\n押してください",
"ごめんなさい\n調子に乗ってました",
"お願いです\n押してください",
"本当に\nすいませんでした"
];
private var tf:TextField;
private var tfW:Number = 0;
public function Fuki2(){
var sp:Sprite = new Sprite();
tf= new TextField();
tf.text = textArr[0];
//tf.autoSize = "middle";
tf.textColor = 0xffffff;
tf.x = 0;
tf.y = -10;
sp.graphics.beginFill(0xffffff);
sp.graphics.drawEllipse(0, 0, 0, 20);
sp.graphics.endFill();
addChild(sp);
sp.buttonMode = false;
sp.mouseEnabled = false;
sp.addChild(tf);
sp.filters= [ new GlowFilter(0xffffff, 1, 10, 10)];
var my_timer:Timer = new Timer(3000);
my_timer.addEventListener(TimerEvent.TIMER, onTime);
my_timer.start();
}
private function onTime(e:TimerEvent):void{
tf.text = textArr[num];
num++
if(num > textArr.length -1){
num = 0;
}
}
}
class Fuki3 extends Sprite{
public var num:int = 0;
private var textArr:Array = ["っと言うのは\nウッソ~(笑)"
];
private var tf:TextField;
private var tfW:Number = 0;
public function Fuki3(){
var sp:Sprite = new Sprite();
tf= new TextField();
tf.text = textArr[0];
//tf.autoSize = "middle";
tf.textColor = 0xffffff;
tf.x = 0;
tf.y = -10;
sp.graphics.beginFill(0xffffff);
sp.graphics.drawEllipse(0, 0, 0, 20);
sp.graphics.endFill();
addChild(sp);
sp.buttonMode = false;
sp.mouseEnabled = false;
sp.addChild(tf);
sp.filters= [ new GlowFilter(0xffffff, 1, 10, 10)];
}
}