flash on 2010-4-13
♥0 |
Line 79 |
Modified 2010-04-13 22:53:50 |
MIT License
archived:2017-03-10 07:28:20
ActionScript3 source code
/**
* Copyright kihon ( http://wonderfl.net/user/kihon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iZ2U
*/
package
{
import com.bit101.components.PushButton;
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{
private var isPlaying:Boolean = false;
public function Main()
{
graphics.beginFill(0x0);
graphics.drawRect(0, 0, 465, 465);
graphics.endFill();
var gause:LifeGause = new LifeGause();
gause.x = 430;
gause.y = 15;
addChild(gause);
new PushButton(this, 175, 400, "OK",
function():void
{
if (isPlaying) return;
isPlaying = true;
var plus:Boolean = (gause.hp == 0) ? true : false;
addEventListener
(
Event.ENTER_FRAME,
function():void
{
if (plus) gause.hp++;
else gause.hp--;
gause.update();
if (gause.hp == 0 || gause.hp == 35)
{
isPlaying = false;
removeEventListener(Event.ENTER_FRAME, arguments.callee);
}
}
);
});
}
}
}
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
class LifeGause extends Sprite
{
public var hp:int = 35;
private var life:Sprite;
public function LifeGause()
{
graphics.beginFill(0xFFFFFF);
graphics.drawRoundRect(0, 0, 25, 130, 5, 5);
graphics.endFill();
var black:Sprite = new Sprite();
black.graphics.beginFill(0x16181A);
black.graphics.drawRoundRect(3, 3, 19, 105, 2, 5);
black.graphics.endFill();
black.filters = [new DropShadowFilter(1)];
addChild(black);
life = new Sprite();
life.x = 5;
addChild(life);
update();
}
public function update():void
{
life.graphics.clear();
for (var y:int = 0; y < hp; y++)
{
var matrix:Matrix = new Matrix();
matrix.createGradientBox(15, 3, 0);
life.graphics.lineStyle(1.0, 0x393939);
life.graphics.beginGradientFill("linear", [0x9F9678, 0xD7CCA8, 0x9F9678], [1.0, 1.0, 1.0], [50, 128, 205], matrix);
life.graphics.drawRect(0, 105 - y * 3, 15, 3);
life.graphics.endFill();
}
}
}