Greetings All,
I'm trying to do more and more of my projects with external classes and,
along with that, creating classes for routines that I regularly do. I have a
class that reads an XML file and CSS file once it's called. It has worked
fine for the first few projects I used it in. With my recent project, it's
not wanted to behave. The code for the class is as follows:
package {
import flash.display.Sprite;
import flash.text.StyleSheet;
import flash.events.*;
import flash.net.*;
public class fileImports extends Sprite {
public var newStyleSheet:StyleSheet = new StyleSheet();
public var newXML:XML = new XML();
public function fileImports(xmlFile:String, cssFile:String):void {
//load css file
var cssToLoad:URLRequest=new URLRequest(cssFile);
var cssLoader:URLLoader = new URLLoader;
cssLoader.load(cssToLoad);
//load xml file
var xmlToLoad:URLRequest=new URLRequest(xmlFile);
var xmlLoader:URLLoader = new URLLoader;;
xmlLoader.load(xmlToLoad);
//event listeners
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
}
public function cssLoaded(event:Event):void {
newStyleSheet.parseCSS(event.target.data);
}
public function xmlLoaded(event:Event):void {
newXML = XML(event.target.data);
}
}
}
I am creating an instance on my main timeline with this:
var fileForThis:fileImports = new
fileImports("courseInfo.xml","styles.css");
I am trying to use the data that is coming in with the XML file to populate
some combo boxes. My problem is I don't know how to "listen" to the class
from the main timeline to find out if the class is finished processing the
XML. Right now if I try to use "fileForThis.newXML" I get a value of null.
But if I put a trace on newXML in the class, it shows the content of my XML
file.
I have gotten this to work on other projects because I haven't tried to use
the data immediately - so the data has time to "process" before it's put
into a text field, etc.
I appreciate any help I can get on this. Thanks!
D. Dane Williams
The Learning Center
Buckman Laboratories, International
901-272-6774
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com