ont

give_up.swf

ont
Jul 18th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.giveup {
  2.     import flash.events.*;
  3.     import flash.media.*;
  4.     import flash.display.*;
  5.     import flash.net.*;
  6.     import flash.text.*;
  7.     import flash.utils.*;
  8.  
  9.     public class GiveUpApp extends MovieClip {
  10.  
  11.         private var experTise:String;
  12.         public var timer:MovieClip;
  13.         private var elapsed:int = 0;
  14.         private var deadLine:int = 0;
  15.         private var started:Boolean;
  16.         private var startedMessage:String = "counting down...";
  17.         private var stats:SharedObject;
  18.         private var stoppedMessage:String = "Countdown stop";
  19.         public var messagetf:TextField;
  20.         private var giveUpMessage:String = "It's time to give up. Try this:\n<table>\n<tr><td></td></tr>\n</table> ";
  21.         private var myTimer:Timer;
  22.  
  23.         public function GiveUpApp(){
  24.             var _local1:*;
  25.             deadLine = 0;
  26.             elapsed = 0;
  27.             giveUpMessage = "It's time to give up. Try this:\n<table>\n<tr><td></td></tr>\n</table> ";
  28.             stoppedMessage = "Countdown stop";
  29.             startedMessage = "counting down...";
  30.             super();
  31.             stats = SharedObject.getLocal("/giveup/stats");
  32.             if (stats.data.starts == undefined){
  33.                 stats.data.starts = 0;
  34.             };
  35.             if (stats.data.stops == undefined){
  36.                 stats.data.stops = 0;
  37.             };
  38.             if (stats.data.giveups == undefined){
  39.                 stats.data.giveups = 0;
  40.             };
  41.             messagetf.text = ((("starts: " + stats.data.starts) + "\ngive-ups: ") + stats.data.giveups);
  42.             trace(">>>>> GiveUp");
  43.             _local1 = 47;
  44.             timer.colon.stop();
  45.             timer.pauseBtn.visible = false;
  46.             deadLine = (_local1 * 60);
  47.             timer.startBtn.addEventListener(MouseEvent.CLICK, start);
  48.             timer.pauseBtn.addEventListener(MouseEvent.CLICK, pause);
  49.         }
  50.         function toggleUi(){
  51.             timer.startBtn.visible = !(timer.startBtn.visible);
  52.             timer.pauseBtn.visible = !(timer.pauseBtn.visible);
  53.         }
  54.         function timeFormat(_arg1:String, _arg2:int){
  55.             while (_arg1.length < _arg2) {
  56.                 _arg1 = ("0" + _arg1);
  57.             };
  58.             return (_arg1);
  59.         }
  60.         function start(_arg1:MouseEvent){
  61.             if (!started){
  62.                 stats.data.starts++;
  63.                 myTimer = new Timer(1000, deadLine);
  64.                 tick(null);
  65.                 timer.colon.play();
  66.                 messagetf.text = startedMessage;
  67.                 myTimer.addEventListener("timer", tick);
  68.                 myTimer.addEventListener("timerComplete", giveItUp);
  69.                 myTimer.start();
  70.             } else {
  71.                 trace("timer already started");
  72.                 myTimer.start();
  73.             };
  74.             toggleUi();
  75.             timer.startBtn.visible = false;
  76.             timer.pauseBtn.visible = true;
  77.             started = true;
  78.         }
  79.         function tick(_arg1:TimerEvent){
  80.             var _local2:*;
  81.             var _local3:*;
  82.             var _local4:*;
  83.             elapsed++;
  84.             _local2 = (deadLine - elapsed);
  85.             _local3 = Math.floor((_local2 / 60));
  86.             _local4 = (_local2 % 60);
  87.             timer.minutes.text = timeFormat(_local3, 2);
  88.             timer.seconds.text = timeFormat(_local4, 2);
  89.         }
  90.         function giveItUp(_arg1:TimerEvent){
  91.             var _local2:Sound;
  92.             elapsed = 0;
  93.             stats.data.giveups++;
  94.             started = false;
  95.             timer.colon.gotoAndStop(1);
  96.             _local2 = new Buzz();
  97.             _local2.play();
  98.             toggleUi();
  99.             messagetf.text = giveUpMessage;
  100.             timer.minutes.text = (timer.seconds.text = "00");
  101.         }
  102.         function pause(_arg1:MouseEvent){
  103.             myTimer.stop();
  104.             toggleUi();
  105.         }
  106.  
  107.     }
  108. }//package com.giveup
  109. package giveup_fla {
  110.     import flash.display.*;
  111.     import flash.text.*;
  112.  
  113.     public dynamic class timer_1 extends MovieClip {
  114.  
  115.         public var colon:MovieClip;
  116.         public var seconds:TextField;
  117.         public var pauseBtn:SimpleButton;
  118.         public var startBtn:SimpleButton;
  119.         public var minutes:TextField;
  120.  
  121.     }
  122. }//package giveup_fla
  123. package {
  124.     import flash.media.*;
  125.  
  126.     public dynamic class Buzz extends Sound {
  127.  
  128.     }
  129. }//package
Advertisement
Add Comment
Please, Sign In to add comment