Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  {
  2.     import flash.display.MovieClip;
  3.     import flash.text.TextField;
  4.     import flash.text.TextFormat;
  5.     import flash.events.Event
  6.     import flash.media.SoundChannel;
  7.     import flash.events.MouseEvent;
  8.    
  9.     public class countdownCode extends MovieClip{
  10.  
  11.         public function countdownCode() {
  12.            
  13.             var bell:temple = new temple();
  14.            
  15.             var cNum:Number;
  16.             cNum = 10;
  17.            
  18.             //keep track of the frame we're on
  19.             var fNum:Number;
  20.             fNum=0;
  21.            
  22.             var resetButton:reset = new reset ();
  23.             addChild(resetButton);
  24.             resetButton.x=270
  25.             resetButton.y=380
  26.             resetButton.height=40
  27.             resetButton.width=90
  28.             resetButton.buttonMode=true
  29.            
  30.             //text
  31.             var t:TextField = new TextField ();
  32.             addChild(t);
  33.             t.x=255
  34.             t.y=10
  35.             t.text = String(cNum)
  36.             t.width = 500
  37.             t.height=500
  38.            
  39.             //changing text properties
  40.             var tf:TextFormat = new TextFormat ();
  41.             tf.size=40
  42.             tf.font = "Comic Sans MS";
  43.             tf.color= 0xFFFFFF
  44.            
  45.             //put the text field and text format together!!
  46.             t.setTextFormat(tf);
  47.            
  48.             //clock arms
  49.             var c:clock = new clock
  50.             addChild(c);
  51.             c.x=275;
  52.             c.y=200;
  53.             c.width=5
  54.            
  55.             addEventListener(Event.ENTER_FRAME, mainFun);
  56.             function mainFun(e:Event):void {
  57.                
  58.                 fNum++; //fNum+=1
  59.                 c.rotation +=15
  60.                
  61.                 if (fNum == 24){
  62.                     cNum--
  63.                     t.text = String(cNum)
  64.                     t.setTextFormat(tf);
  65.                    
  66.                     //reset fNum back to 0 every second (24 f/s)
  67.                     fNum=0
  68.                    
  69.                     //make the temple bell go when the clock hits zero
  70.                     if (cNum == 0){
  71.                         var myChannel2:SoundChannel = bell.play();
  72.                         t.visible = false
  73.                         c.visible = false
  74.                     }
  75.                    
  76.                     resetButton.addEventListener(MouseEvent.CLICK,resetButtonFun);
  77.                     function resetButtonFun (e:MouseEvent):void {
  78.                         cNum = 10;
  79.                        
  80.                         if (cNum==10){
  81.                         t.visible = true
  82.                         c.visible = true
  83.                         }
  84.                     }
  85.                 }
  86.                
  87.                
  88.             }
  89.            
  90.         }
  91.  
  92.     }
  93.    
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement