Hi,
I have some problems in using Singleton pattern. First I defined a function as below. I stored the config from the remote server.
function getConfigFromRemote() as Object
if m.configFromRemote = Invalid then
m.configFromRemote = loadConfigFromServer()
end if
return m.configFromRemote
end function
I first called this function in main(), here it sends the request to remote server for the first time and returned the config data. Then in the Scene Graph Node I defined called homeScene.xml, I imported the file that contained this getConfigFromRemote() function, and called the function again for the config, and I find out that the m.configFromRemote is actually invalid and it has to request from remote again. I can assure that the
getConfigFromRemote() in homeScene.xml is called after the function get called in main(). Its in key pressed event actually.
Does anybody have any idea of why is that? and how should I use Singleton in this case?