# Variable help please! Should be easy :)

**URL:** https://forum.kirupa.com/t/variable-help-please-should-be-easy/215215
**Category:** flash
**Created:** [February 5, 2007, 2:50pm UTC](https://forum.kirupa.com/t/variable-help-please-should-be-easy/215215 "2007-02-05T14:50:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Macsy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/macsy/32/3238_2.png) [@Macsy](https://forum.kirupa.com/u/Macsy)
#### Post date: [February 5, 2007, 2:50pm UTC](https://forum.kirupa.com/t/variable-help-please-should-be-easy/215215/1 "2007-02-05T14:50:46Z")

</div>

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
