2010-03-16 34 views
0

對不起,我是新來閃我有這行代碼:閃存型鑄造出了錯

  BaseEntry(_entryList[i]).topTeamName = ((Team)(teamList.getNameAtIndex(i*2))).Name; 

,我得到的錯誤:

TypeError: Error #1034: Type Coercion failed: cannot convert "[object Team]" to ncaa.Data.Team.

什麼我需要做的修理它?

回答

1

我想你要找的是什麼,而不是:

((Team)(teamList.getNameAtIndex(i*2))).Name 

你想:

(teamList.getNameAtIndex(i*2) as Team).Name 
1

@walpolea是對的,而是爲了完整起見,你也可以這樣來做:

BaseEntry(_entryList[i]).topTeamName = Team(teamList.getNameAtIndex(i*2)).Name; 

其中許多人認爲是更快然後使用「作爲」。