actionscript 3 - Countdown timer not working in AS3 -


since im new in as3 , converted as2 as3. countdown doesnt work. right 4 digits looping in same time fast (the 3 digits animation fine - ignore it)

see countdown - http://magnixsolutions.com/clients/ot/media-buys_scoreboard-redux_160x600_5-8-2009.html

as3

// current date , time exists @ // instance in time when frame entered var currentdate:date = new date(); var thisyear:int = currentdate.getfullyear(); var thismonth:int = currentdate.getmonth(); var thisdate:int = currentdate.getdate(); var thishour:int = currentdate.gethours(); var thisminute:int = currentdate.getminutes(); var thissecond:int = currentdate.getseconds() + 12; var thismsecond:int = currentdate.getmilliseconds();  // date( year, month-1, date [, hour [, minute [, second [, millisecond]]]]) var eventdate = new date(thisyear, thismonth, thisdate, thishour, thisminute,        thissecond, thismsecond); var eventmillisecs = eventdate.gettime();  // current date , time exists @ // instance in time when frame entered this.addeventlistener(timerevent.timer, enterframehandler); function enterframehandler() { currentdate = new date(); var currentmillisecs = currentdate.gettime();  this.msecs = eventmillisecs - currentmillisecs;  if (this.msecs <= 0){     play();     return; }  // if date hasn't been reached, continue // devise seconds, minutes, hours , days // calculated milliseconds this.secs = math.floor(this.msecs/1000); // 1000 milliseconds make second this.mins = math.floor(this.secs/60); // 60 seconds make minute this.hours = math.floor(this.mins/60); // 60 minutes make hour this.days = math.floor(this.hours/24); // 24 hours make second  this.msecs = int(this.msecs % 1000); this.secs = int(this.secs % 60); this.mins = int(this.mins % 60); this.hours = int(this.hours % 24); this.days = int(this.days);  while (this.msecs.length < 3) this.msecs = "0" + this.msecs; if (this.secs.length < 2) this.secs = "0" + this.secs; if (this.mins.length < 2) this.mins = "0" + this.mins; if (this.hours.length < 2) this.hours = "0" + this.hours; while (this.days.length < 3) this.days = "0" + this.days;  for(var movie in this){     if (this[movie]._parent == this) this[movie].evaluateframefrom(this);  } };  movieclip.prototype.evaluateframefrom = function(variableclip){ var namearray = this._name.split("_"); var numberset = variableclip[namearray[0]]; var character:int = parseint(namearray[1]);     var frame = 1 + parseint(numberset.charat(character)); if (this._currentframe != frame) this.gotoandstop(frame); }; 

this mean:

// there no number type in as3. use parseint cast string int var character:int = parseint(namearray[1]); var frame = 1 + parseint(numberset.charat(character)); 

also, there's no such thing _root in actionscript 3.0. try this:

this.avgscore_mc.gotoandplay(2); 

and need add enterframe this:

this.addeventlistener(event.enter_frame, enterframehandler);  function enterframehandler() {     // stuff in enter frame } 

sounds you're still thinking 2.0!


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -