Repeating Functions, variable won't change. Reeeallly confusing
Okay.. so yea, I'm trying to repeat a function that basically will attachmovie on a "tileset", an image depending on the parameter.
It's called AddID(i), and currently there's only 2 valid options, 0 and 1, images showing, X and O.
There's a Button, and theres an array and a function that shows an image of the tile depending on its ID value loaded from the array.
My problem is:
Everything works just great as if you repeat the function by clicking again, but...
When repeating the function by code, all the tiles will have the Image of the last tile added.
This is my timeline actionscript code.
IDonTile = new Array();
IDonTile = [0,0,1,0,0,1];
_global.Tile=0;
And this is my buttoncode.
on(release){
AddID(IDonTile[_global.Tile]); // This function Adds the Tile to my screen
Tilelist.text+=TileSlot[_global.Tile]; // This is actually a debug textfield to see what value is supposed to be loaded
_global.Tile+=1; // This is so the next time a tile is added, next array value will be used as ID.
}
This, works just fine!!
If i click this button 6 times, i will have in the following order : X,X,O,X,X,O
The debug text field will show : 0,0,1,0,0,1
BUT
I want to add all 6 tiles instantly, I would just use the function in a for loop, or repeat the code 6 times, Like this:
on(release){
for(i=0;i<5;i++){
AddID(IDonTile[_global.Tile]); // This function Adds the Tile to my screen
Tilelist.text+=TileSlot[_global.Tile]; // This is actually a debug textfield to see what value is supposed to be loaded
_global.Tile+=1; // This is so the next time a tile is added, next array value will be used as ID.
}
}
The Debug Text field will Show : 0,0,1,0,0,1
Which is actually correct
BUT ALL 6 TILES WILL BE : O,O,O,O,O,O
That's 6 O's.
The AddID(i) Function is only 10 lines long.
I don't want to manually Add my 6 tiles, what if i had 100 tiles ![]()
I was wondering, is there something wrong on Actionscript 2?
Should I move on to Actionscript 3 maybe it will work??
Because, if I can manually click the button, and it works, it should be the exact same thing if i code it by a foor loop, Correct???
I am reaaaallly confuseddd T,T it shouldn't beee like thisss ![]()
Please help !!
I thanks in advance for any replies..
Cause last time I tried asking for help, I got none...