A Global Singleton is a class of which only one instance exists within a program.

Any attempt to use non-static members of the class involves performing operations on this one instance.




-- parent script "SingletonDemo"
 
property _instance
property _someProperty
 
----------------------------------------
-- @constructor
----------------------------------------
on new (me)
  if not voidP(me.script._instance) then return me.script._instance
  me.script._instance = me
  me._someProperty = 0
  return me
end
 
----------------------------------------
-- sample method
----------------------------------------
on someMethod (me, x)
  me._someProperty = me._someProperty + x
  return me._someProperty
end