![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: as3, cs3, flash, singleton |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| Here's an easier version of the singleton class - similarly used in the Caingorm framework for AS3. The key is that the constructor is void and doesn't allow instantiation of itself ![]() Code: package com.layeronemedia {
/**
* One-Instance enforced singleton that instantiates and contains the data
* as a DataCollection and the controls as the ControlCollection.
*/
public class Controller {
private static var _instance:Controller;
/**
* Public static method to instantiate the Controller object.
* @return Controller Object Instance
*/
public static function getInstance():Controller {
if (_instance == null) {
_instance = new Controller();
}
return _instance;
}
public function Controller():void {
_Do all your Stuff Here
}
}
} __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
| The Following User Says Thank You to ccoonen For This Useful Post: | ||
HelloWorld (02-08-2008) | ||
| |
| |||
| Absolutely bro! I can start you out from the beginning ![]() __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
![]() |
| Thread Tools | |
| Display Modes | |
| |