Copy link to clipboard
Copied
I am using cs4 w/as3. I have a keyframe with as3 that is supposed to decide which scene to procede with based on the time of day.
The problem arises when the code gets to the gotoAndPlay command, it doesn't process unless it's the last line in the code.
See code example below.
In this example, no matter what time of day it is, it always jumps to scene "Blue" because it's the last one.
currenttime = new Date();
hrs=currenttime.hours;
mins=currenttime.minutes;
secs=currenttime.seconds;
if (hrs==10&&mins<15) {
gotoAndPlay(1, "Black");
}
if (hrs==10&&mins<30) {
gotoAndPlay(1, "Orange");
}
if (hrs==10&&mins<45) {
gotoAndPlay(1, "Silver");
}
if (hrs==10&&mins<60) {
gotoAndPlay(1, "Pink");
}
if (hrs==11&&mins<15) {
gotoAndPlay(1, "Blue");
}
Copy link to clipboard
Copied
My guess is that something else is going on if the last is always selected since hrs must == 11 to get in there. YOu need to use a trace to see what the values are that you are getting for the hrs, mins, and secs values.
Still, the logic you are employing is not going to work for you as you have it written out. You should make use of "else" in the conditionals as well so that you stop the processing when a valid set of conditions is satisfied, otherwise you are bound to miss the right condition.
For example,
if (hrs==10&&mins<15) { // if this is true
if (hrs==10&&mins<30) { // then this is also true, as are any others with a 10 for hrs
Find more inspiration, events, and resources on the new Adobe Community
Explore Now