After reading a tutorial of Flash, I am still not sure what exactly is the program flow in general:
Specifically, I have a demo of a flash game (sort of super mario style). In it I have two types of weapon – a simple fire and big fireball. I reviewed the code in order to learn flash better [I am very new – since around monday this week].
I saw that the program has a variable that keeps track of the number of uses I have left in each weapon. I tried to review all the places this variable was used but I couldn’t find where it affects the drawing onto the screen.
I even tried removing the variable declaration and then testing it – so I may find all references to the variable — By the way any convinient way of finding all references to a variable/method/class [I am using ADOBE FLASH CS5.5]?
Also, I tried changing the variables starting value to “12” and I noticed that when I test the game, the weapon has 12 uses indeed.
So my problem:
1. It seems that this variable is somehow affecting the drawing. Yet, I don’t know how it does so since all the code I have found that uses this variable has nothing to do with drawing. It is all, logic, like
if(var <= 0){
var--;
} else{
return false;
}
Where is this influence coming from?
- Any way to get all references to a variable [like in eclipse ctrl+shift+g]?
Thank you very much.
Flash can have code on a variety of different things.
Depending on the tutorial they will put code on any and all of them and it makes it very hard to follow. In general it is always best to place code in external classes and only on frames when absolutely necessary. AS3, in fact, does not let you put code directly on movie clips to avoid just the problem you’re having.
I’m going to assume you’re using AS2 because of your problem of not finding code alongside of the fact you said you deleted the declaration of the variable and everything still worked. (AS2 lets you get away with a lot)
If you unlock any layers that are locked and select all, you might find almost invisible movies that appear as just dots. Lots of bad tutorials put code on invisible movies like that to run everything. Deselect everything, select just that movie clip and then hit [F9] to pull up the action window to see the code.
The other option is that the code is just on a movieclip somewhere. Start clicking on them and looking in the action window to see if there is anything there.
No matter what it sounds like you’re using a bad example. Search for AS3 tutorials as that is a more optimized version of actionscript and it prevents a lot of bad practices like what you’re seeing.
An AS3 tutorial I just came accross
[edited]
To further answer your question, program flow happens with the flash VM first firing an onEnterFrame event which any movieclip can listen to. (In AS2 it would call onEnterFrame on every movieclip. This was abandoned in favor of the event so your class does not have to update on every frame) Once that has happened the VM then draws everything to screen. For a more complete overview I found this website
Your problem sounds like everything is contained in external classes. Here’s an example