Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.giveup {
- import flash.events.*;
- import flash.media.*;
- import flash.display.*;
- import flash.net.*;
- import flash.text.*;
- import flash.utils.*;
- public class GiveUpApp extends MovieClip {
- private var experTise:String;
- public var timer:MovieClip;
- private var elapsed:int = 0;
- private var deadLine:int = 0;
- private var started:Boolean;
- private var startedMessage:String = "counting down...";
- private var stats:SharedObject;
- private var stoppedMessage:String = "Countdown stop";
- public var messagetf:TextField;
- private var giveUpMessage:String = "It's time to give up. Try this:\n<table>\n<tr><td></td></tr>\n</table> ";
- private var myTimer:Timer;
- public function GiveUpApp(){
- var _local1:*;
- deadLine = 0;
- elapsed = 0;
- giveUpMessage = "It's time to give up. Try this:\n<table>\n<tr><td></td></tr>\n</table> ";
- stoppedMessage = "Countdown stop";
- startedMessage = "counting down...";
- super();
- stats = SharedObject.getLocal("/giveup/stats");
- if (stats.data.starts == undefined){
- stats.data.starts = 0;
- };
- if (stats.data.stops == undefined){
- stats.data.stops = 0;
- };
- if (stats.data.giveups == undefined){
- stats.data.giveups = 0;
- };
- messagetf.text = ((("starts: " + stats.data.starts) + "\ngive-ups: ") + stats.data.giveups);
- trace(">>>>> GiveUp");
- _local1 = 47;
- timer.colon.stop();
- timer.pauseBtn.visible = false;
- deadLine = (_local1 * 60);
- timer.startBtn.addEventListener(MouseEvent.CLICK, start);
- timer.pauseBtn.addEventListener(MouseEvent.CLICK, pause);
- }
- function toggleUi(){
- timer.startBtn.visible = !(timer.startBtn.visible);
- timer.pauseBtn.visible = !(timer.pauseBtn.visible);
- }
- function timeFormat(_arg1:String, _arg2:int){
- while (_arg1.length < _arg2) {
- _arg1 = ("0" + _arg1);
- };
- return (_arg1);
- }
- function start(_arg1:MouseEvent){
- if (!started){
- stats.data.starts++;
- myTimer = new Timer(1000, deadLine);
- tick(null);
- timer.colon.play();
- messagetf.text = startedMessage;
- myTimer.addEventListener("timer", tick);
- myTimer.addEventListener("timerComplete", giveItUp);
- myTimer.start();
- } else {
- trace("timer already started");
- myTimer.start();
- };
- toggleUi();
- timer.startBtn.visible = false;
- timer.pauseBtn.visible = true;
- started = true;
- }
- function tick(_arg1:TimerEvent){
- var _local2:*;
- var _local3:*;
- var _local4:*;
- elapsed++;
- _local2 = (deadLine - elapsed);
- _local3 = Math.floor((_local2 / 60));
- _local4 = (_local2 % 60);
- timer.minutes.text = timeFormat(_local3, 2);
- timer.seconds.text = timeFormat(_local4, 2);
- }
- function giveItUp(_arg1:TimerEvent){
- var _local2:Sound;
- elapsed = 0;
- stats.data.giveups++;
- started = false;
- timer.colon.gotoAndStop(1);
- _local2 = new Buzz();
- _local2.play();
- toggleUi();
- messagetf.text = giveUpMessage;
- timer.minutes.text = (timer.seconds.text = "00");
- }
- function pause(_arg1:MouseEvent){
- myTimer.stop();
- toggleUi();
- }
- }
- }//package com.giveup
- package giveup_fla {
- import flash.display.*;
- import flash.text.*;
- public dynamic class timer_1 extends MovieClip {
- public var colon:MovieClip;
- public var seconds:TextField;
- public var pauseBtn:SimpleButton;
- public var startBtn:SimpleButton;
- public var minutes:TextField;
- }
- }//package giveup_fla
- package {
- import flash.media.*;
- public dynamic class Buzz extends Sound {
- }
- }//package
Advertisement
Add Comment
Please, Sign In to add comment