I am having an issue with scope in a class created in flash. I am creating an application that utilizes XML to create an array of information that I will manipulate and re-save to XML.
I have a document class that is calling calling another class that I am using to load the XML, convert it into an array and return the array to the document constructor using a method. I have successfully parsed the XML and created an array of the data but can't seem to add data to the array via the processXML function inside the loadXMLData class.
I stripped out all the stuff from the code that doesn't matter. Here is the basic representation of what i am trying to do.
My Document Class
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.*;
public class dashBoard extends MovieClip {
public var newData
//initialize the dashBoard
public function dashBoard(){
//construct the Dashboard Object
trace("Dashboard Initialized");
trace("|--------------XML Data--------------|");
newData = new loadXMLData();
trace(newData.getSections());
}
}
}
My loadXMLData Class
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.*;
public class loadXMLData extends MovieClip {
//initialize an array that will be used in the document class
public var sectionList:Array = new Array();
public function loadXMLData() {
//load the xml file containing the data
var myLoader = new URLLoader();
myLoader.load(new URLRequest("dashboard.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
//process the xml file after it loads
//and create an object
var newXML:XML = new XML(e.target.data);
//then I use the XML to populate my
//array i declared at the top
//this is a simple test
sectionList[0] = "test";
}
}
//and this is the method i use in the document class
//to get the sectionList array
public function getSections():Array{
return sectionList;
}
}
}
It seems pretty straightforward but I can't seem to edit the array. The document class always returns a blank array. Any Ideas?