public var:NoOfElements = 0;
public function addElement(){
// increases NoOfElements by one in every call
}
public function remvoveElement(){
// decreases NoOfElements by one in every call
}
addElement and removeElement is called by two separate timer events. And in each method it modifies the global variable NoOfElements. Is there a method to synchronize variables in acionscript ?
Flash is “thread safe” because it actually runs in only one thread, so you don’t need to worry about synchronizing anything. The timer will run your function and you can be sure it won’t be run twice simultaneously.
So, to answer your question – no there’s no method to “synchronize variables” because there’s no need for one.