# Dispatch event from singleton

**URL:** <https://forum.kirupa.com/t/dispatch-event-from-singleton/319533>\
**Category:** Uncategorized\
**Created:** [February 23, 2011, 11:53pm UTC](https://forum.kirupa.com/t/dispatch-event-from-singleton/319533 "2011-02-23T23:53:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [February 23, 2011, 11:53pm UTC](https://forum.kirupa.com/t/dispatch-event-from-singleton/319533/1 "2011-02-23T23:53:19Z")

</div>

So I have this class “G” that I use for global vars, and that kind stuff.

Now I want to dispatch an event from that class and no matter what I do the compiler throws the same error: “Call to a possibly undefined method dispatchEvent.”

I have already tried extending the EventDispatcher class…

```auto

package {	
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.events.EventDispatcher;
		
	public class G extends EventDispatcher{
		public static var v:Object = {};
		public static var scope:Array = [];
		public static var xml;		
		static var cargadorXml;

		
		public static function initXml():void {
			cargadorXml = new URLLoader(); 
			cargadorXml.addEventListener(Event.COMPLETE, loaded); 
			cargadorXml.load(new URLRequest("config.xml"));
		}
		
		public static function loaded(e):void {
			xml = new XML(cargadorXml.data);
			dispatchEvent(new Event("xml"));
		}
	}
}

```

What am I doing wrong?
