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. :) 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

My code checks to see if the hour that is current is in the sunrise or sunset array and so for my code, how would I check to see if "theHour" is one of the values in either array and if its not in one, check the other?
That is basically what I am trying to accomplish I should say.
Thanks for your help..

Best,
Karl


On May 21, 2009, at 4:04 PM, Mark Winterhalder wrote:

Hmm... maybe I misunderstood what you were trying to do.

Do you want to have a continuous sunrise and -set over 24h, or do you
want to have a sudden sunset or -rise twice a day?

Mark


On Thu, May 21, 2009 at 10:57 PM, Mark Winterhalder <[email protected]> wrote:
On Thu, May 21, 2009 at 10:43 PM, Karl DeSaulniers <[email protected]> wrote:
Thanks Mark.
That is an interesting approach.
Pardon me for asking, but what part in your code initiates the sunset part?

Nothing really, if you mean how the change is triggered. But whenever
the code runs, it will adjust the alpha.
For testing, you can put all of it into an onEnterFrame(), but for
production use you should run it only once when the page loads. If you
really expect visitors to spend hours on your site, then use
setInterval() to update it every couple of minutes.

The general idea of the code is to calculate what fraction of 12h the
current time is away from the begin of sunset, and then adjust the
alpha accordingly. So, "sunset" here really means that it's the
darkest minute of the day, just when it begins to get brighter.

Mark


Karl

Sent from losPhone

On May 21, 2009, at 3:34 PM, Mark Winterhalder <[email protected]> wrote:

Hi,

I *think* this does what you're trying to do, which would be to fade the alpha of an image in and out again over 24h. I don't have AS2 so I can't test, but when you do, you can set minutesPerDay to however long you may wish to sit there and watch the magic happen. If it happens,
that is, because as I said it's untested.
Please, reconsider putting it into an enterFrame handler. It's really
enough to run it every couple of minutes.

Also, no, unfortunately I have no idea why Flash is acting up for you.
The operator use appears to be correct.


var sunrise : Number = 6; // hour of day when sun begins to rise
var maxAlpha : Number = 100;

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[
var alpha : Number = Math.abs( 0.5 - cycleElapsed ) * 2 * maxAlpha;

BKGND.BKGND_Grad._alpha = alpha;


HTH,
Mark




On Thu, May 21, 2009 at 7:14 AM, Karl DeSaulniers <[email protected]>
wrote:

EEEk.. anyone!!!

What am I doing wrong?? This is AS2.

var sunrise:Array = new Array("6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17");
var sunset:Array = new Array("18", "19", "20", "21", "22", "23", "0",
"1",
"2", "3", "4", "5");

var time:Date = new Date();
var hour:Number = time.getHours();
var hours:String = hour.toString();
var snRSE:String = sunrise[hours];
var snSET:String = sunset[hours];

this.onEnterFrame = function() {
      if (hours == snRSE) {
              BKGND.BKGND_Grad._alpha -= BKGND.BKGND_Grad._alpha +
8.33333333333;
      } else if (hours == snSET) {
              BKGND.BKGND_Grad._alpha += BKGND.BKGND_Grad._alpha +
8.33333333333;
      }
};

I feel this is probably so easy, but it is eluding me for some reason.
flash says for this line:

if (hours == snRSE) {

 - "operator "=" must be followed by an Operand" ???


Karl DeSaulniers
Design Drumm
http://designdrumm.com

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to