Oh, I forgot to remove the onEnterFrame when it's no longer needed. Please add this line to the end of the function:
if( progress >= 1 ) delete this.onEnterFrame; Mark On Fri, May 22, 2009 at 12:18 AM, Mark Winterhalder <mar...@gmail.com> wrote: > On Thu, May 21, 2009 at 11:44 PM, Karl DeSaulniers <k...@designdrumm.com> > wrote: >> Oh no, I am just wanting to check what time of day it is and have my >> background fade from dark to light accordingly. >> The code you supplied, I think will do that, just haven't got off work yet >> to try out. :) > > Well, it fades out for 12h, then fades back in for 12h, beginning at > 6am each day. > > But now I think I really know what you mean. We can recycle most of the lines: > > var sunrise : Number = 6; // hour of day when sun begins to rise > var fadeDuration = 100; // as number of frames > > var framesElapsed : Number = 0; > var minutesPerDay : Number = 24 * 60; > var time : Date = new Date(); > var minuteOfDay : Number = time.getHours() * 60 + time.getMinutes(); > var deltaMinutes : Number = (minuteOfDay - sunrise * 60 + > minutesPerDay) % minutesPerDay; > var cycleElapsed : Number = deltaMinutes / minutesPerDay; // [0...1[ > > BKGND.BKGND_Grad.onEnterFrame = function () { > var progress : Number = framesElapsed / fadeDuration; > > // here we check if the sun is supposed to set or to rise: > if( cycleElapsed < .5 ) { > // the sun is still rising > this._alpha = (1 - progress) * 100; > } else { > // the sun is setting > this._alpha = progress * 100; > } > }; > >> I am more so wanting to know why, if my code is correct, why its throwing >> this operand error. >> very mysterious and bugging me to no end :-P > > Yeah, I'd like to know that, too. Possibly, closing and restarting > Flash will fix it? It has its mysterious ways sometimes, at least > that's how it used to be. :/ > > Mark > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders