00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS3: What happened to _global?

1,732 Views | 4 Replies
New Topic Respond to this Topic

AS3: What happened to _global? 2007-08-19 01:45:13


AS3:Main

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.

BBS Signature

Response to AS3: What happened to _global? 2007-08-19 04:18:11


maybe because its useless? I have never once seen a valid use for global when there is not an alternative way that is better or cleaner

Response to AS3: What happened to _global? 2007-08-19 04:20:35


Everything I've heard about flash CS3 is so negative. I wish Macromedia was still around. Oh well, at least we can still keep to old skool Flash 8 for now if we aren't adept programmers and not be too far behind...


BBS Signature

Response to AS3: What happened to _global? 2007-08-19 04:25:30


At 8/19/07 04:20 AM, Kajenx wrote: Everything I've heard about flash CS3 is so negative. I wish Macromedia was still around. Oh well, at least we can still keep to old skool Flash 8 for now if we aren't adept programmers and not be too far behind...

I still prefer AS3 to AS2 infinitely. The main problems with CS3 are all the stupid bugs and GUI issues which seem to happen much more often than in Flash 8. I wish they'd release a patch or something.

Also, Delta's right about it being useless. The only instance I can think of where I'd need to use global would be for some silly little site thing if I wanted two .swfs to share information, since apparently global variables affect all active .swfs. There's no serious game or anything where it's been essential or even remotely useful.


BBS Signature

Response to AS3: What happened to _global? 2007-08-19 06:10:18


_global warming o shit get al gore

AS3: What happened to _global?


uh...

BBS Signature