开发者

Button for main screen

I figure out a code for a bus schedule, but i need help creating a main screen before the actual schedule that links to all this code.

THANK YOU to all the people who posted answers before & helped me ALOT !

var myDate:Date = new Date();
var countdown:Number

//Shuttle bus to CSI
var busHours:Array = new Array(); 
busHours[0] = ["2CSI", 7, 05]; 
busHours[1] = ["2CSI", 7, 35]; 
busHours[2] = ["2CSI", 8, 05]; 
busHours[3] = ["2CSI", 8, 35]; 
busHours[4] = ["2CSI", 9, 05]; 
busHours[5] = ["2CSI", 9, 35]; 
busHours[6] = ["2CSI", 10, 05]; 
busHours[7] = ["2CSI", 10, 35];
busHours[8] = ["2CSI", 11, 05];
busHours[9] = ["2CSI", 11, 35];
busHours[10] = ["2CSI", 12, 05];
busHours[11] = ["2CSI", 12, 35];
busHours[12] = ["2CSI", 13, 05];
busHours[13] = ["2CSI", 13, 35];
busHours[14] = ["2CSI", 14, 05];
busHours[15] = ["2CSI", 14, 35];
busHours[16] = ["2CSI", 15, 05];
busHours[17] = ["2CSI", 15, 35];
busHours[18] = ["2CSI", 16, 05];
busHours[19] = ["2CSI", 16, 35];
busHours[20] = ["2CSI", 17, 05];
busHours[21] = ["2CSI", 17, 35];
busHours[22] = ["2CSI", 18, 05];
busHours[23] = ["2CSI", 18, 35];
busHours[24] = ["2CSI", 19, 05];
busHours[25] = ["2CSI", 19, 35];
busHours[26] = ["2CSI", 20, 05];
busHours[26] = ["2CSI", 20, 35];
busHours[26] = ["2CSI", 21, 05];
busHours[26] = ["2CSI", 21, 35];
busHours[26] = ["2CSI", 22, 05];
busHours[26] = ["2CSI", 22, 35];

for (var i:Number = 0; i < busHours.length; i++) { 

if(myDate.hours < busHours[i][1] || myDate.hours == busHours[i][1] && myDate.minutes <= busHours[i][2]){
    trace(busHours[i][1]);
    if(busHours[i][1] == myDate.hours){
        countdown = busHours[i][2] - myDate.minutes;
    } else {
        countdown = 60 - myDate.minutes + busHours[i][2];

    }

    csi.text = "The next Shuttle bus to CSI arrives at " + busHours[i][1] + ":" + busHours[i][2] + " in " + countdown + " minute(s)";
    i += busHours.length;
} else {

    csi.text = "There are no more Shuttle buses arriving at The College of Staten Island at this time.";

}

}

//Shuttle Bus to ferry
var FerrybusHours:Array = new Array(); 
FerrybusHours[0] = ["2Ferry", 7, 35]; 
FerrybusHours[1] = ["2Ferry", 8, 05]; 
FerrybusHours[2] = ["2Ferry", 8, 35]; 
FerrybusHours[3] = ["2Ferry", 9, 05]; 
FerrybusHours[4] = ["2Ferry", 9, 35]; 
FerrybusHours[5] = ["2Ferry", 10, 05]; 
FerrybusHours[6] = ["2Ferry", 10, 35]; 
FerrybusHours[7] = ["2Ferry", 11, 05];
FerrybusHours[8] = ["2Ferry", 11, 35];
FerrybusHours[9] = ["2Ferry", 12, 05];
FerrybusHours[10] = ["2Ferry", 12, 35];
FerrybusHours[11] = ["2Ferry", 13, 05];
FerrybusHours[12] = ["2Ferry", 13, 35];
FerrybusHours[13] = ["2Ferry", 14, 05];
FerrybusHours[14] = ["2Ferry", 14, 35];
FerrybusHours[15] = ["2Ferry", 15, 05];
FerrybusHours[16] = ["2Ferry", 15, 35];
FerrybusHours[17] = ["2Ferry", 16, 05];
FerrybusHours[18] = ["2Ferry", 16, 35];
FerrybusHours[19] = ["2Ferry", 17, 05];
FerrybusHours[20] = ["2Ferry", 17, 35];
FerrybusHours[21] = ["2Ferry", 18, 05];
FerrybusHours[22] = ["2Ferry", 18, 35];
FerrybusHours[23] = ["2Ferry", 19, 05];
FerrybusHours[24] = ["2Ferry", 19, 35];
FerrybusHours[25] = ["2Ferry", 20, 05];
FerrybusHours[26] = ["2Ferry", 20, 35];
FerrybusHours[27] = ["2Ferry", 21, 05];
FerrybusHours[28] = ["2Ferry", 21, 35];
FerrybusHours[29] = ["2Ferry", 22, 05];
FerrybusHours[30] 开发者_Go百科= ["2Ferry", 22, 35];
FerrybusHours[31] = ["2Ferry", 23, 05];

for (var f:Number = 0; f < FerrybusHours.length; f++) { 

if(myDate.hours < FerrybusHours[f][1] || myDate.hours == FerrybusHours[f][1] && myDate.minutes <= FerrybusHours[f][2]){
    trace(FerrybusHours[f][1]);
    if(FerrybusHours[f][1] == myDate.hours){
        countdown = FerrybusHours[f][2] - myDate.minutes;
    } else {
        countdown = 60 - myDate.minutes + FerrybusHours[f][2];

    }

    ferry.text = "The next Shuttle bus to the Ferry Terminal arrives at " + FerrybusHours[f][1] + ":" + FerrybusHours[f][2] + " in " + countdown + " minute(s)";
    f += FerrybusHours.length;
} else {

    ferry.text = "There are no more Shuttle buses arriving at the ferry terminal at this time.";

}


}


From your post it sounds like you're working in the Flash IDE and coding in the timeline. If that isn't the case then you might want to ignore this.

You could just add an event listener to check for when your button/movieclip is clicked and place your bus code and assets on the second frame. On the first frame put your button with the code:

button.addEventListener(MouseEvent.CLICK,clickButton);
function clickButton(e:MouseEvent){
   gotoAndStop(2);
}

Now when you click the button it should move to frame 2 and run your bus code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜