2011-05-16 210 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