I don't like Adobe for a ton of reasons involving AS3. One of them is the complete removal of _global for no good reason. Although the alternative does make perfect sense, what was the point in giving us ActionScripters yet another hurtle to jump through on our way to understanding? But I digress. This isn't supposed to be a rant, just me telling you how you're supposed to do _global in AS3.
First, you're going to have to make a class. Then you're going to have to give it static variables, and then you can access those variables in a static way from any scope and pretty much use them as _global, except maybe in a cleaner way. If you understand that great. You can stop reading now. If you got confused by the first sentence, well, I have help.
If you don't know what a class is, you're in for a bit of a learning experience. I suggest you start here with Inglor's tutorial.
To have Flash be able to deal with classes, I usually have to put the entire project in C:\. I think this may just be a rarity with my computer, but if nothing else seems to be working, I suggest you try that. You won't need to use any import or include statements.
Now you have to learn about static variables. If something is static, that means that it doesn't affect just 1 instance of a class (I hope Inglor taught you what that is :), it effects all of them. You can declare a variable static by going
static var lives;
(inside a class definition of course) and you can access it by (assuming that the name of the class is global)
global.lives;
Remember, global isn't an instance name. It's the name of the class. That's why it can be accessed anywhere. How convenient, since that was the missing functionality we needed!
Now I think you should see where I'm going with this. What I did was
package {
public class global {
public static var highScore:int= 0;
public function global() {
}
}
}
in my global.as file and accessed it with
global.highScore=1337; //or something
in my main file.
Anyway, I hope that clears things up. It's a bit confusing.
Come join music competitions on Chips Compo and hang on our Discord!
Good artists copy. Great artists get banned from the Audio Portal.