# Scope in classes

**URL:** <https://forum.kirupa.com/t/scope-in-classes/244721>\
**Category:** Uncategorized\
**Created:** [November 21, 2007, 5:16am UTC](https://forum.kirupa.com/t/scope-in-classes/244721 "2007-11-21T05:16:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![qpixo](https://avatars.discourse-cdn.com/v4/letter/q/c4cdca/32.png) [@qpixo](https://forum.kirupa.com/u/qpixo)\
**Post date:** [November 21, 2007, 5:16am UTC](https://forum.kirupa.com/t/scope-in-classes/244721/1 "2007-11-21T05:16:22Z")

</div>

I tried to experiment some xml parsing stuffs and found that interesting link about scope in classes @adobe:

[http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs\_Parts&file=00001662.html](http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001662.html)

_Now in this example on the onload function, they use:  
prodXml.onLoad = function(success:Boolean) {  
if (success) {  
/_ If the XML successfully loads and parses,  
set the class’s m\_products\_xml variable to the parsed  
XML document and call the init function. _/  
thisObj.m\_products\_xml = this;  
thisObj.init();  
} else {  
/_ There was an error loading the XML file. \*/  
trace(“error loading XML”);  
}  
};

Can I create a simple function then call it while using a delegate class to solve the scope  
issue instead??

ex:  
function parseXML (success:Boolean)  
{  
if (success) {  
thisObj.m\_products\_xml = this;  
thisObj.init();  
} else {  
trace(“error loading XML”);  
}  
}  
then use:  
prodXml.onLoad = Delegate.create(this, parseXML);

While experimenting it, since “thisObj” is declared in local constructor  
it won’t recognize in this function. If I declared as a global variable  
I got that error msg from the compiler:

“Type mismatch in assigment statement: found com.parseXML where XML is required…”

btw, I put the as file in com directory and .fla outside of com directory though

thanks in advance!
