2011-05-16 171 views
-1

我想出了一个公交时刻表的代码,但是我需要帮助在实际的时间表之前创建一个主屏幕,链接到所有这些代码。主屏幕按钮

非常感谢所有在&之前发帖回复的人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] = ["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."; 

} 


} 
+0

你的问题是什么?你想实现什么?什么是你的“主屏幕”? – DanielB 2011-05-16 14:49:22

+0

你在问什么太模糊。你需要将你的项目分解成必要的部分,并发布不起作用的东西。你有一些代码,很好。但你想用它做什么? – Bosworth99 2011-05-16 14:51:40

+0

我的主屏幕只是一个按钮,您可以按,然后进入该代码。整个代码正在工作,它只是我需要知道什么代码放在它只是“goToAndPlay”,然后呢? – 2011-05-16 22:26:39

回答

1

从你的文章看来,你听起来像你在Flash IDE中工作,并在时间轴上编码。如果不是这种情况,那么你可能会忽略这一点。

您可以添加一个事件侦听器来检查您的按钮/动画片段单击时间,并将您的总线代码和资产放置在第二帧上。在第一帧把你的按钮,代码:

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

现在,当您单击按钮就应该移动到帧2和运行总线代码。

+0

非常感谢你! – 2011-05-16 23:47:08