I need to find a simple tutorial or example of implementing a getInstance method in a class, and then invoking it.
Here's what I have so far, but it is not working.
var asdf:Blah = Blah.getInstance();
var a = Blah.getInstance().geta();
mx.controls.Alert.show(a);
var a = Blah.getInstance().geta();
mx.controls.Alert.show(a);
package
{
public class Blah
{
public var a:String = null;
public function Blah() {
// constructor
seta('a');
}
private static var _self:Blah = null;
public static function getInstance():Blah {
if(_self = null) _self = new Blah();
return _self;
}
public function seta(b:String):void {
a = b;
}
public function geta():String {
return a;
}
}
}
{
public class Blah
{
public var a:String = null;
public function Blah() {
// constructor
seta('a');
}
private static var _self:Blah = null;
public static function getInstance():Blah {
if(_self = null) _self = new Blah();
return _self;
}
public function seta(b:String):void {
a = b;
}
public function geta():String {
return a;
}
}
}
I get the following error: Cannot access a property or method of a null object reference.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.