An object that is declared static goes on the class object instead of on the instance object.  In general there is only one copy of the class object in memory so a variable declared there will save you some space.  So if you are talking about things like constants a static variable is a good thing to use.  A function on the other hand generally does not take so much memory that you get a lot of benefit out of it being static.  So if the function is truly a utility, fine, make it static, but don’t try to go optimizing code by changing functions on a class into statics, you won’t see much benefit.

 

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Pradeep Chaudhary
Sent: Friday, October 21, 2005 1:35 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Doubts about static keyword

 

Can anybody please explain me how the static keyword works in Flex. As
per my understanding staic variable or a method is created in memory
just once and is shared after that.
If i create a static method in a Actionscript class, is it actually
created just once in memory?.
Is it similar to _javascript_ functions which are created on loading of the page?

Does having static methods really save memory usage.

Thanks in advance.

Pradeep



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to