• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

OOP using global vars, best way to do it?

Guest
May 04, 2012 May 04, 2012

Copy link to clipboard

Copied

Ls,

Im a beginner when it comes to OOP.

Not wanting to pass everything thru the class calls, i want to be able to have  some  application globals.

Can  define them package level?

Should I create a class globals.as with static vars?

Whats the proper way of doing this?

Any help is greatly appreaciated.

Mac

TOPICS
ActionScript

Views

931

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , May 04, 2012 May 04, 2012

firstly I would say that there are few instances where you would need global variables, I haven't used any in a long time and at the moment I can't think of any situation where i would. Although saying that it may be the easier solution if you are new to OOP.

if I were to do this I would use a class with statics vars as you said

Votes

Translate

Translate
Advocate ,
May 04, 2012 May 04, 2012

Copy link to clipboard

Copied

firstly I would say that there are few instances where you would need global variables, I haven't used any in a long time and at the moment I can't think of any situation where i would. Although saying that it may be the easier solution if you are new to OOP.

if I were to do this I would use a class with statics vars as you said

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2012 May 04, 2012

Copy link to clipboard

Copied

yes, you can use a class that has static variables.  if you want your class to validate the variables, you can use private static variables and public getters and settings.  otherwise, you can use public static variables.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 04, 2012 May 04, 2012

Copy link to clipboard

Copied

Thank you both!

I noticed that now im understanding OOP a bit better I finf great pleasure in the way things are accessible.

In one case though I have somve very large vectors.

I thought it would benefit performance if I could just access these directly from any class.

Mac

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 04, 2012 May 04, 2012

Copy link to clipboard

Copied

LATEST

I dont use glabal vars anymore, more like a global class in the form of a Model that I inject into views (via presenters) using Swiz

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines