Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-07-2012, 05:16 AM   #1
MichaelBaker
Registered User
 
Join Date: Sep 2008
Posts: 12
Default Objects and Optimization

I got in the habit of creating a global variable object that contains all global variables used in the class...
private var core = {
varOne:"blahOne",
varTwo:"blahTwo"
};
then through the class i would just use core.varOne and so on. I started this because i once needed two class to be able to adjust the core variables of each other and instead of creating public get/set properties for each variable i just had to create one that referenced the core object.

Now im wondering optimization wise, how much does using core.varOne differ from just varOne. Im working with particles and a lot of variables and im wondering if using this method is slowing me down...

Thanks
MichaelBaker is offline   Reply With Quote
Old 07-08-2012, 11:45 PM   #2
Sonny
Senior Member
 
Join Date: Aug 2010
Location: Sydney,Australia
Posts: 132
Default

When you do create a object . flash compiler doesnt validate it . (ie) the type is figured at run time . So when you refer to core.varOne. 1) the compiler doesnt know what core.varOne is . or if core.varOne even exists. Also if you just use core.varOne there is a fat chance varOne never got declared. So the compiler would still compile yet there will be run time crashes..( If refering to objects I prefer the array access and checking it for undefined. as in core["varOne"]) .Unless really required for some reason I prefer to avoid it. But programming is a field of needs and requirements .So you might have to choose between one or the other depending on what you want I guess.
Sonny is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:06 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.