# Custom Class Pointers

**URL:** <https://forum.kirupa.com/t/custom-class-pointers/238594>\
**Category:** flash\
**Created:** [September 12, 2007, 10:35pm UTC](https://forum.kirupa.com/t/custom-class-pointers/238594 "2007-09-12T22:35:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dail](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@dail](https://forum.kirupa.com/u/dail)\
**Post date:** [September 12, 2007, 10:35pm UTC](https://forum.kirupa.com/t/custom-class-pointers/238594/1 "2007-09-12T22:35:15Z")

</div>

Hi,

Ok, so I’ve got my head around AS3 from a procedural approach, but I now want to write more code in class form.

As I do a bit with XML, I’ve written this little class for handling XML URL requests. Basically you pass it a url and a call back function you want notified when the XML is loaded. Similar to what you can do using the built in URL loader classes etc. I wanted to achieve that “Black Box” approach however, when I just have to create a new instance of a class and pass it the info I want, getting back what I want, without having to edit the class each time I want to pass it a different XML file url.

So, looking at the below, am I on the right track with this approach. This is the first AS3 class I have attempted to write.

Here is the class:

```php
package {
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.events.*;
	import flash.net.URLRequest;
	import flash.net.URLLoader;

	public class loadXml extends Sprite {
		public var myXML:XML;
		public var myXLoader:URLLoader
		private var myXMLURL:URLRequest
		private var XML_URL:String
		
		public function loadXml(url:String, callBack:Function) {
			myXML = new XML();
			XML_URL = url;
			myXMLURL = new URLRequest(XML_URL);
			myXLoader = new URLLoader(myXMLURL);
			myXLoader.addEventListener("complete", callBack);			
		}
		
	}
}

```

And here is how I instantiate it and use it on the main timeline or in my documents class etc.

```php
var testXML:XML = new XML();
var myloadXml:loadXml = new loadXml("gallery1.xml", checkLoad)

function checkLoad(evt:Event){
	testXML = XML(evt.target.data)
	trace(testXML)//outputs raw XML data, to be accessed how you see fit.
}

```

Things I have yet to figure out, are simply passing the class a var that the class will add the XML data to for me, and destroying the class event listener I create for the loading complete event.
