Hi there,
I had tried searching this for the last 2 hours =[ so I decided to give in and ask.
I am have a number of variables defined in my document class and I have noticed that if I were to call a function in the same class to edit the value of the variable, the change would only apply to the scope of the function.
Now I hope I used scope in the right context there =D
Here is my code to show what I mean:
package {
import flash.display.*;
import flash.xml.*;
import flash.events.*;
import com.xml.xmlLoad;
import com.gui.mainGui;
public class main extends MovieClip {
private var _targetURL:String = "Musicinfo.xml";
private var getXMLLoad:xmlLoad;
private var getGui:mainGui;
public var xmlData:XML;
public var _lessonInfo:XMLList;
public function main() {
loadXML(_targetURL);
processXML();//This will return TypeError: Error #1009:
//Cannot access a property or method of a null object reference.
//at main/::processXML()
trace(xmlData);//This will also return an error similar to above
}
function loadXML(_targetURL) {
getXMLLoad = new xmlLoad(_targetURL);
getXMLLoad.addEventListener(Event.COMPLETE, onComplete);
}
function onComplete(evt:Event) {
xmlData = getXMLLoad.getXML();
trace(xmlData.fileInfo.blurb);//This traces the XML data
trace(xmlData.fileInfo.author);//And so does this
}
function processXML() {
trace(xmlData.fileInfo.blurb);//This dosen't =[
}
}
}
Could someone explain why this is?
This may be a AS2 understanding but I thought that if I at changed the value of a variable made in the class, then the value would be the new value for every time the variable was called after the new value was put there.