#1
| |||
| |||
Singleton in AS2 Hiya I'm struck with a question about implementing a Singleton class in AS2. I'm doing a project on nav/tracking frame, for that i need only one instance of the shell class. this is the method that ever noted mySingleton.getInstance().doMethod(); Wouldn't it be easier to make doMethod a static function? mySingleton.doMethod(); Also, if I want to assign my lone class to a _global var, does that cause any problems? And how can i do import com.MyClass; _global.shell = MyClass; is this actual way? thanks..... |
#2
| |||
| |||
Re: Singleton in AS2 Normally we all use a Singleton when you want to access a class from multiple places,indeed you should make sure that all those references point to a single instance of the class but on the same time, static class methods are called on the class itself, and have no instance at alll. Static methods are better for one time function calls, that do not rely on retaining data between calls now If you want to go for the Singleton method, no need to make it a global variable,because any object that references mySingleton.getInstance() will return the same instance of the Singleton object.... good for you..... |
#3
| |||
| |||
Re: Singleton in AS2 Well many times when you need only one instance of an object.In fact in many cases Singletons are the core classes of the Model View Controller Pattern,which is core to just about every Flash Application you’ll ever create. Further, it may be inappropriate, resource hungry or less efficient to have multiple instances. |
#4
| |||
| |||
Re: Singleton in AS2 For abstract classes, it's not supported, never have been, but still confused whether or not they ever will be in ActionScript. Trying to create them anyway using runtime exceptions just seems ridiculous to me.. If you are going to use ActionScritp, then learn ActionScript and program in ActionScript. When you program in, python, you have a different mindset, different tools and features than you do ...... |
![]() |
|
Tags: as2, singleton |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Exception Handling in Singleton | Bottlenecked | Software Development | 6 | 20-09-2010 09:14 PM |
Serializable Singleton Implementation in Java | Bhardwaj | Software Development | 5 | 18-02-2010 07:17 PM |
Program for singleton objects which returns two instances | Sarfaraj Khan | Software Development | 5 | 02-02-2010 12:37 PM |
Single instance of singleton for all JVMs | KANAN14 | Software Development | 3 | 30-10-2009 07:10 PM |
What is a Singleton in java? | Bhim | Software Development | 3 | 02-03-2009 08:18 PM |