Sp@ds | 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 :
- // VARIABLES__________________________
- var d0;
- var d1;
- var d2;
- var h0;
- var h1;
- var m0;
- var m1;
- var s0;
- var s1;
- var yr;
- var mo;
- var da;
- var ho;
- var mi;
- var nextYear:Boolean;
- var timeScript:String;
- var now_date:Date;
- var load_xml:XML;
- var isSound:Boolean;
- // sound
- var tick_sound = new Sound();
- tick_sound.attachSound("tick" );
- tick_sound.setVolume(25);
- // FUNCTIONS__________________________
- startCountdown = function ( yr:Number,mo:Number,da:Number,ho:Number,mi:Number,nextYear:Boolean,timeScript:String,color, snd ):Void
- {
- // do colours
- d0_txt.textColor = Number("0x"+color);
- d1_txt.textColor = Number("0x"+color);
- d2_txt.textColor = Number("0x"+color);
- h0_txt.textColor = Number("0x"+color);
- h1_txt.textColor = Number("0x"+color);
- m0_txt.textColor = Number("0x"+color);
- m1_txt.textColor = Number("0x"+color);
- s0_txt.textColor = Number("0x"+color);
- s1_txt.textColor = Number("0x"+color);
- this.yr = yr;
- this.mo = mo;
- this.da = da;
- this.ho = ho;
- this.mi = mi;
- this.nextYear = nextYear;
- this.timeScript = timeScript;
- this.isSound = (snd.length) ? true : false;
- getCurrentTime();
- }
- getCurrentTime = function ()
- {
- if (this.timeScript == "" )
- {
- this.now_date = new Date();
- checkMSecsRemaining();
- }
- else
- {
- trace("loadXML" );
- // load mktime from php script
- // using XML
- //
- // <data><ms>12345678</ms></data>
- //
- load_xml = new XML();
- load_xml.ignoreWhite = true;
- load_xml.onLoad = function (success)
- {
- // parse me
- if (success)
- {
- //trace(this.toString());
- var ms = Number(this.firstChild.firstChild.firstChild.nodeValue) * 1000;
- now_date = new Date( ms );
- checkMSecsRemaining();
- }
- }
- load_xml.load( this.timeScript );
- }
- }
- checkMSecsRemaining = function ()
- {
- startMSecsRemaining = getMSecsRemaining(yr,mo,da,ho,mi); // seconds to xmas at the start of the film
- if (startMSecsRemaining)
- setControlMC();
- else
- setDisplay();
- }
- setControlMC = function ()
- {
- this.createEmptyMovieClip( "control_mc", 0 );
- control_mc.onEnterFrame = function ()
- {
- this._parent.setDisplay();
- }
- }
- getMSecsRemaining = function (year:Number, mon:Number, day:Number, hour:Number, min:Number)
- {
- // get the number of milliseconds to enddate based on system time
- if (!year) year = now_date.getFullYear();
- var end_date = new Date( year, mon-1, day, hour, min );
- // if today's date is larger than chosen date, increase to next year
- if ( end_date.getTime() < now_date.getTime() && !this.nextYear )
- {
- // target date is in the past, set countdown to 0
- return 0;
- }
- else
- {
- while ( end_date.getTime() < now_date.getTime() )
- end_date.setYear( Number(end_date.getFullYear()) + 1 );
- return Math.floor( end_date.getTime() - now_date.getTime() );
- }
- }
- getMSecsElapsed = function ()
- {
- return Math.floor( getTimer() );
- }
- setChar = function (part:String, val:String)
- {
- if (this[part] != val)
- {
- this[part+"_txt"].text = this[part] = val;
- if (part == "s1" && tick_sound.getVolume() && isSound)
- { // tick each second
- tick_sound.start();
- tick_sound.setVolume( tick_sound.getVolume()-1 );
- }
- }
- }
- leadingZeros = function (str:String, no:Number)
- {
- while (str.length < no)
- str = "0"+str;
- return str;
- }
- setDisplay = function ()
- {
- var msecs = startMSecsRemaining - getMSecsElapsed(); // updated msecs to xmas;
- if (msecs > 0) {
- temp_date = new Date (msecs);
- var d = Math.floor( msecs/86400000 );
- var h = Math.floor( (msecs - (d*86400000)) / 3600000 );
- var m = temp_date.getMinutes().toString();
- var s = temp_date.getSeconds().toString();
- d = leadingZeros(d.toString(),3);
- h = leadingZeros(h.toString(),2);
- m = leadingZeros(m,2);
- s = leadingZeros(s,2);
- setChar( "d0", d.charAt(0) );
- setChar( "d1", d.charAt(1) );
- setChar( "d2", d.charAt(2) );
- setChar( "h0", h.charAt(0) );
- setChar( "h1", h.charAt(1) );
- setChar( "m0", m.charAt(0) );
- setChar( "m1", m.charAt(1) );
- setChar( "s0", s.charAt(0) );
- setChar( "s1", s.charAt(1) );
- }
- else
- {
- d0_txt.text = "0";
- d1_txt.text = "0";
- d2_txt.text = "0";
- h0_txt.text = "0";
- h1_txt.text = "0";
- m0_txt.text = "0";
- m1_txt.text = "0";
- s0_txt.text = "0";
- s1_txt.text = "0";
- }
- }
|
|