Hi. Im making a game with 2 players ( there will be more, up to 10 players but im starting with 2 players.
This is my code:
init = function () {
var speed:Number = 2;
var players = 2;
//Spelare 1
var p1Left:String = “Key.DOWN”;
var p1Right:String = “Key.UP”;
var p1Color:Number= 0xFFFF00;
//Spelare 2
var p2Color:Number = 0x0000FF;
var p2Left:String = “90”;
var p2Right:String = “88”;
// Skapa spelarnas text och färg
for (i=1; i<(players+1); i++) {
var currentPlayer:String = “p”+i+“Text”;
var currentColor:Number = “p”+i+“Color”;
var textFormation:TextFormat = new TextFormat();
textFormation.color = currentColor;
this.createTextField(currentPlayer, this.getNextHighestDepth(), 100, (i*10), 100, 100);
currentPlayer.text = "Player "+i;
currentPlayer.setTextFormat(textFormation);
trace(currentPlayer);
}
};
init();
This goes in the first Frame, You should be able to do this copy this into your flash and you will see my problem.
I get 3 errors… none of them i can solve.
plz help!
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 15: Type mismatch in assignment statement: found String where Number is required.
var currentColor:Number = “p”+i+“Color”;
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 19: There is no property with the name ‘text’.
currentPlayer.text = "Player "+i;
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 20: There is no method with the name ‘setTextFormat’.
currentPlayer.setTextFormat(textFormation);
Total ActionScript Errors: 3 Reported Errors: 3