# I dont want to my class to extend anything?

**URL:** https://forum.kirupa.com/t/i-dont-want-to-my-class-to-extend-anything/255712
**Category:** flash
**Created:** [March 26, 2008, 7:49am UTC](https://forum.kirupa.com/t/i-dont-want-to-my-class-to-extend-anything/255712 "2008-03-26T07:49:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![stuluk28](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/stuluk28/32/2775_2.png) [@stuluk28](https://forum.kirupa.com/u/stuluk28)
#### Post date: [March 26, 2008, 7:49am UTC](https://forum.kirupa.com/t/i-dont-want-to-my-class-to-extend-anything/255712/1 "2008-03-26T07:49:23Z")

</div>

Hi all,

I’ve been struggling with this for a while and figured it would be better to seek some advice from the kirupa forums as you guys have much more knowledge of as3 than me.

I am trying to build a simple debug class so I can debug remotely on projects I create. I got my class working using the singleton pattern so that it is only instantated once and it will trace fine, but when I try to add a TextField to the stage I get errors. I can’t use addChild unless the class extends a DisplayObjectContainer, but if my class extends anything it throws an error.

The basic code is below for your thoughts? thanks?

```auto
package 
{
	import flash.display.DisplayObjectContainer
	import flash.text.TextField;
	
	public class Debug extends DisplayObjectContainer
	{
		private static var VERSION:String = "0.1";
		private static var _instance:Debug; // enforce singleton pattern Debug instance
		private var _textField:TextField;
		
		// static function to trace to debugger console
		public static function write(args)
		{
			if(_instance == null)
			{
				_instance = new Debug(arguments.callee);
			}
			// output arguments
			trace(arguments);
			// :TODO: send the arguments to the console
		}
		
		public function Debug(caller:Function = null)
		{
			if(caller != Debug.write)
			{
				throw new Error("Debug is a singleton pattern class, use write() instead");
			}
			if(Debug._instance != null)
			{
				throw new Error("Only one Debug instance should be instantiated");
			}
			// initialize the console
			createConsole();
		}
		
		private function createConsole():void
		{
			// create Debug console here
			trace(" ***New Debugger - " + VERSION + "***")
			// :TODO: create the textfield and console
			this._textField = new TextField();
			this._textField.width = 200;
			this._textField.height = 200;
			//addChild(this._textField);
		}
	}
}

```
