# This. reference in an object

**URL:** <https://forum.kirupa.com/t/this-reference-in-an-object/2657>\
**Category:** Uncategorized\
**Created:** [May 16, 2002, 6:13pm UTC](https://forum.kirupa.com/t/this-reference-in-an-object/2657 "2002-05-16T18:13:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 16, 2002, 6:13pm UTC](https://forum.kirupa.com/t/this-reference-in-an-object/2657/1 "2002-05-16T18:13:19Z")

</div>

I am trying to make a module to load and parse some xml and have run into some problems so I made this sample code to work with it. The code works fine if I have a reference (see the line with **) the setVariables method with the name jObject.setVariables, but when I use: this.setVariables :it doesn’t work. When I use: trace(this); : it prints the whole XML document. Any Ideas? \r\r\r\r\rmyTry = function(myObjName){ \rthis.name = myObjName; \rtrace(“myTry object made”); \r} \rmyTry.prototype.name; \rmyTry.prototype.myXMLDoc; \rmyTry.prototype.eventNum = null; \rmyTry.prototype.eventTitles = new Array(); \rmyTry.prototype.eventDescriptions = new Array(); \rmyTry.prototype.eventReferences = new Array(); \rmyTry.prototype.myLoadEm = function(success){ \rif(!success ){ \rtrace(“Your document didn’t load”); \r\r}else{ \rtrace(“Your document loaded”); \rtrace("::::::::::::::::::::::\<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/ohwell.gif ALT=":"\> n" +this + "  
"); \r**\*\*\*\*\*\* this.setVariables(); \*\*\*\*\*\*\*\*\*\*\*\*\* \r//trace(myXMLDoc); \r} \r} \r\rmyTry.prototype.makeIt = function(){ \rmyXMLDoc = new XML(); \rmyXMLDoc.load(“T1.xml”); \rmyXMLDoc.ignoreWhite = true; \rmyXMLDoc.onLoad = this.myLoadEm; \r} \r\rmyTry.prototype.setVariables = function (){ \rtrace(“In the setVariables”); \rthis.eventNum = myXMLDoc.firstChild.childNodes.length; \r\rfor(i=0;i this.eventTitles = myXMLDoc.firstChild.childNodes.attributes.title; \rthis.eventDescriptions = myXMLDoc.firstChild.childNodes.firstChild.firstChild.firstChild; \rthis.eventReferences = new Array();[//XMLData.firstChild.childNodes.firstChild.childNodes](https://XMLData.firstChild.childNodes.firstChild.childNodes);//.nextSibling.firstChild; \rthis.eventNum = myXMLDoc.firstChild.childNodes.firstChild; \rfor(j=0;j.firstChild.firstChild.nextSibling.childNodes.length; j++){ \rthis.eventReferences[j] = myXMLDoc.firstChild.childNodes.firstChild.firstChild.nextSibling.childNodes[j].firstChild; \r} \rtrace(this.eventReferences); \r} \rreturn 1; \r} \r\rjObject = new myTry(jObject); \rjObject.makeIt(); \rtrace(jObject.name); \robj2 = new myTry(“blamb!!!”); \rtrace(obj2.name);
