flash on 2012-2-16
♥0 |
Line 105 |
Modified 2012-02-16 06:59:55 |
MIT License
archived:2017-03-20 14:56:12
ActionScript3 source code
/**
* Copyright pedude ( http://wonderfl.net/user/pedude )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/grAZ
*/
package
{
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.events.*;
public class Poke extends Sprite
{
private var bgb:Sprite;
private var bgt:Sprite;
private var plyText:MovieClip;
private var texts:TextField;
private const TEXT_BOX_MARGIN:int = 10;
private var tim:Timer;
private var smooth_tim:Timer;
private const TEXT_BOX_DIST:int = 16;
private var enemy:Sprite;
private var you:Sprite;
private var enemyXPos = stage.stageWidth - 50;
private var enemy
public function Poke()
{
init();
// begin();
}
public function init():void
{
bgb = new Sprite();
addChild(bgb);
bgb.x = 0;
bgb.y = 0;
bgb.graphics.beginFill(0x00FFFF);
bgb.graphics.drawRect(0, stage.stageHeight/2, stage.stageWidth, stage.stageHeight/2);
bgb.graphics.endFill();
bgt = new Sprite();
addChild(bgt);
bgt.x = 0;
bgt.y = 0;
bgt.graphics.beginFill(0x00FF00);
bgt.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight/2);
bgt.graphics.endFill();
plyText = new MovieClip();
addChild(plyText);
plyText.x = 0;
plyText.y = 0;
plyText.graphics.beginFill(0x00FF00);
plyText.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight/2);
plyText.graphics.endFill();
texts = new TextField();
texts.background = true;
texts.x = 0;
texts.y = 0;
texts.backgroundColor = 0xC0C0C0;
texts.height = stage.stageHeight/2 - 2*TEXT_BOX_MARGIN;
texts.width = stage.stageWidth - 2*TEXT_BOX_MARGIN;
texts.border = true;
addChild(texts);
texts.x = stage.stageWidth;
texts.y = stage.stageHeight/2+TEXT_BOX_MARGIN;
addChild(enemy);
addChild(you);
enemy = new Sprite();
enemy.x = 0;
enemy.y = 0;
enemy.graphics.lineStyle(1, 0x000000);
enemy.graphics.beginFill(0xFFFF00);
enemy.graphics.drawRect(0,0, 50,100);
enemy.graphics.endFill();
you = new Sprite();
you.x = 0;
you.y = 0;
you.graphics.lineStyle(1, 0x000000);
you.graphics.beginFill(0xFF00FF);
you.graphics.drawRect(0,0, 25,50);
you.graphics.endFill();
tim = new Timer(2000);
tim.addEventListener(TimerEvent.TIMER, startGame);
tim.start();
}
public function startGame(evt:TimerEvent):void
{
tim.stop();
tim.removeEventListener(TimerEvent.TIMER, startGame); begin();
}
public function begin():void
{
smooth_tim = new Timer(40);
smooth_tim.addEventListener(TimerEvent.TIMER, moveTextBox);
smooth_tim.start();
}
public function moveTextBox(evt:TimerEvent):void
{
if (texts.x <= TEXT_BOX_MARGIN)
{
smooth_tim.removeEventListener(TimerEvent.TIMER, moveTextBox);
smooth_tim.stop();
}
else
{
texts.x -= TEXT_BOX_DIST;
}
if (texts.x <=
if (texts.x < TEXT_BOX_MARGIN) texts.x = TEXT_BOX_MARGIN;
}
}
}