hello i have been programming a game completely in the .fla file because thats how i did it in as2. it was working fine until recently i hit 1500 lines of code. now, when i add code or add varaibles, it randomly says there are too many { or }. the program is wrong because before i add the variable it says it is fine. i do not add any extra brackets to get that error. i think it has too much code so i need to separate it into classes.
i am new to classes and need help moving my .fla code to the new .as files. so i made a new class called ‘soldieractions.as’ the code in it is like so…
package
{
import flash.display.MovieClip;
public class soldieractions
{
function soldiermovement():void {
‘and all the actions for this class are here’
}
}
}
and in the .fla file i put
var testsoldieractions:soldieractions = new soldieractions();
and also
testsoldieractions.soldiermovement();
to be repeated.
when i played the file it gave a ton of errors.
it kept saying stuff like
soldieractions.as line 11----1120:access of undefined property soldiers.
this is because in my .fla file i have an array called soldiers. i guess i need to move that array into the .as file but then i need to use that array other class files for bullet detection and other things.
it also gives errors like
soldieractions.as line 20----1120:access of undefined property player
‘player’ is the instance name of the players movie clip on the stage of the .fla. how can i code the game in the .as file so it recognizes the movie clips in the library and the movie clips on the stage? please help this is very frustrating thank you