countdown pour le new years

countdown pour le new years - Flash/ActionScript - Programmation

Marsh Posté le 21-12-2008 à 18:44:46    

bonsoir
 
Pour la soirée du nouvel an que j'organise je souhaite projeter sur écran le compte a rebour officiel de la soirée. J'ai trouvé une petite application fash sur le net que j'ai modifié a mes besoins.  
Pour le moment mon horloge décompte correctement, par contre je souhaiterais qu'une fois l'heure a 00:00:00 un msg "bonne année" ou qlqchose dans le style apparaisse a l'écran.
 
Je n'arrive pas a effectuer cette tache. j'ai pense qu'avec un gotoAndStop ("2" ) qui s'effectuerai quand tout les champs texte seront a 0 sa marcherait mais je n'y suis pas arriver.
 
voici mon code si vous savez m'aider se serai bien aimable.
 

Code :
  1. // VARIABLES__________________________
  2. var d0;
  3. var d1;
  4. var d2;
  5. var h0;
  6. var h1;
  7. var m0;
  8. var m1;
  9. var s0;
  10. var s1;
  11. var yr;
  12. var mo;
  13. var da;
  14. var ho;
  15. var mi;
  16. var nextYear:Boolean;
  17. var timeScript:String;
  18. var now_date:Date;
  19. var load_xml:XML;
  20. var isSound:Boolean;
  21. // sound
  22. var tick_sound = new Sound();
  23. tick_sound.attachSound("tick" );
  24. tick_sound.setVolume(25);
  25. // FUNCTIONS__________________________
  26. startCountdown = function ( yr:Number,mo:Number,da:Number,ho:Number,mi:Number,nextYear:Boolean,timeScript:String,color, snd ):Void
  27. {
  28. // do colours
  29. d0_txt.textColor = Number("0x"+color);
  30. d1_txt.textColor = Number("0x"+color);
  31. d2_txt.textColor = Number("0x"+color);
  32. h0_txt.textColor = Number("0x"+color);
  33. h1_txt.textColor = Number("0x"+color);
  34. m0_txt.textColor = Number("0x"+color);
  35. m1_txt.textColor = Number("0x"+color);
  36. s0_txt.textColor = Number("0x"+color);
  37. s1_txt.textColor = Number("0x"+color);
  38. this.yr = yr;
  39. this.mo = mo;
  40. this.da = da;
  41. this.ho = ho;
  42. this.mi = mi;
  43. this.nextYear = nextYear;
  44. this.timeScript = timeScript;
  45. this.isSound = (snd.length) ? true : false;
  46. getCurrentTime();
  47. }
  48. getCurrentTime = function ()
  49. {
  50. if (this.timeScript == "" )
  51. {
  52.  this.now_date = new Date();
  53.  checkMSecsRemaining();
  54. }
  55. else
  56. {
  57.  trace("loadXML" );
  58.  // load mktime from php script
  59.  // using XML
  60.  //
  61.  // <data><ms>12345678</ms></data>
  62.  //
  63.  load_xml = new XML();
  64.  load_xml.ignoreWhite = true;
  65.  load_xml.onLoad = function (success)
  66.  {
  67.   // parse me
  68.   if (success)
  69.   {
  70.    //trace(this.toString());
  71.    var ms = Number(this.firstChild.firstChild.firstChild.nodeValue) * 1000;
  72.    now_date = new Date( ms );
  73.    checkMSecsRemaining();
  74.   }
  75.  }
  76.  load_xml.load( this.timeScript );
  77. }
  78. }
  79. checkMSecsRemaining = function ()
  80. {
  81. startMSecsRemaining = getMSecsRemaining(yr,mo,da,ho,mi); // seconds to xmas at the start of the film
  82. if (startMSecsRemaining)
  83.  setControlMC();
  84. else
  85.  setDisplay();
  86. }
  87. setControlMC = function ()
  88. {
  89. this.createEmptyMovieClip( "control_mc", 0 );
  90.  control_mc.onEnterFrame = function ()
  91.  {
  92.   this._parent.setDisplay();
  93.  }
  94. }
  95. getMSecsRemaining = function (year:Number, mon:Number, day:Number, hour:Number, min:Number)
  96. {
  97. // get the number of milliseconds to enddate based on system time
  98. if (!year) year = now_date.getFullYear();
  99. var end_date = new Date( year, mon-1, day, hour, min );
  100. // if today's date is larger than chosen date, increase to next year
  101. if ( end_date.getTime() < now_date.getTime() && !this.nextYear )
  102. {
  103.  // target date is in the past, set countdown to 0
  104.  return 0;
  105. }
  106. else
  107. {
  108.  while ( end_date.getTime() < now_date.getTime() )
  109.   end_date.setYear( Number(end_date.getFullYear()) + 1 );
  110.  return Math.floor(  end_date.getTime() - now_date.getTime()  );
  111. }
  112. }
  113. getMSecsElapsed = function ()
  114. {
  115. return Math.floor( getTimer() );
  116. }
  117. setChar = function (part:String, val:String)
  118. {
  119. if (this[part] != val)
  120. {
  121.  this[part+"_txt"].text = this[part] = val;
  122.  if (part == "s1" && tick_sound.getVolume() && isSound)
  123.  { // tick each second
  124.   tick_sound.start();
  125.   tick_sound.setVolume( tick_sound.getVolume()-1 );
  126.  }
  127. }
  128. }
  129. leadingZeros = function (str:String, no:Number)
  130. {
  131. while (str.length < no)
  132.  str = "0"+str;
  133. return str;
  134. }
  135. setDisplay = function ()
  136. {
  137. var msecs = startMSecsRemaining - getMSecsElapsed(); // updated msecs to xmas;
  138. if (msecs > 0) {
  139.  temp_date = new Date (msecs);
  140.  var d = Math.floor( msecs/86400000 );
  141.  var h = Math.floor( (msecs - (d*86400000)) / 3600000 );
  142.  var m = temp_date.getMinutes().toString();
  143.  var s = temp_date.getSeconds().toString();
  144.  d = leadingZeros(d.toString(),3);
  145.  h = leadingZeros(h.toString(),2);
  146.  m = leadingZeros(m,2);
  147.  s = leadingZeros(s,2);
  148.  setChar( "d0", d.charAt(0) );
  149.  setChar( "d1", d.charAt(1) );
  150.  setChar( "d2", d.charAt(2) );
  151.  setChar( "h0", h.charAt(0) );
  152.  setChar( "h1", h.charAt(1) );
  153.  setChar( "m0", m.charAt(0) );
  154.  setChar( "m1", m.charAt(1) );
  155.  setChar( "s0", s.charAt(0) );
  156.  setChar( "s1", s.charAt(1) );
  157. }
  158. else
  159. {
  160.  d0_txt.text = "0";
  161.  d1_txt.text = "0";
  162.  d2_txt.text = "0";
  163.  h0_txt.text = "0";
  164.  h1_txt.text = "0";
  165.  m0_txt.text = "0";
  166.  m1_txt.text = "0";
  167.  s0_txt.text = "0";
  168.  s1_txt.text = "0";
  169. }
  170. }

Reply

Marsh Posté le 21-12-2008 à 18:44:46   

Reply

Marsh Posté le 21-12-2008 à 19:01:06    

pourquoi du flash ?

Reply

Marsh Posté le 21-12-2008 à 19:09:03    

pourquoi pas ???
 
j'ai quelque notion dans ce logiciel et ca me parait le plus approprié pour réaliser cette application.
et puis si j'arrive a le faire change de frame a 00:00 je pourrais crée une petit animation sympa sans utilisé de la vidéo.
 
tu ferai ça avec quoi toi??

Reply

Marsh Posté le 21-12-2008 à 19:14:10    

si tu fais une animation alors aucun soucis, mais pour çà j'aurais vu quelque chose comme du javascript...
Enfin dans ton cas alors c'est une bonne idée...

Reply

Marsh Posté le 21-12-2008 à 19:19:19    

oui si quelqu'un arrive a m'aider je compte faire clignoté "bonne année" avec un feu d'artifice derrière un truc dans le style. on verra quand j'arriverais a faire apparaitre qlqchose.

Reply

Marsh Posté le 23-12-2008 à 13:12:31    

personne n'a une solution pour moi =[

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed