i expect some sarcasm but what the heck. i have searched the actionscript reference page and can’t seem to find how to declare simple global variable.
i expect some sarcasm but what the heck. i have searched the actionscript reference
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are a couple of good answers already. I just want to point out that
YOU CANcreate global variables in AS3. Just create a file, for example, MyGlobal.as in root of your classes folder:And you can access it as
MyGlobalbecause it is in the top most package. This technique can be used in several not so destructive ways. For example you can have a global constant which is similar to a singleton but instead of being static it will be just an instance of some class:Update; not from the original poster
I had never heard of this before so I put together a quick sample:
In the root directory:
A test class:
And the test application:
Run the app and the trace does indeed show up twice with the correct ‘bla’ value.