Malfist
Malfist

Reputation: 31795

Flash type casting gone wrong

Sorry, I'm new to flash I have this line of code:

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

and I get the error:

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

What do I need to do to fix it?

Upvotes: 0

Views: 219

Answers (2)

heavilyinvolved
heavilyinvolved

Reputation: 1575

@walpolea is right... but for the sake of completeness you can also do it this way:

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

which many argue is faster then using "as".

Upvotes: 1

walpolea
walpolea

Reputation: 165

I think what you're looking for is, instead of:

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

you want:

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

Upvotes: 1

Related Questions