Hello,
I’m trying to set up a class file that will read a bunch of links from an XML document so I can populate some buttons on the stage. The problem I am having is gaining access to the links within the class file. I have no clue how to get at “theWebsite” from the main document. Any help would be greatly appreciated!
This is what I have so far
Class file:
package {
import flash.display.MovieClip;
import flash.display.*;
import flash.text.*;
import flash.net.*;
import flash.events.*;
public class xmlLinkLoader{
//VARIABLES & Event Listeners HERE
trace("xml Link Loader CLASS Imported");
public var theText:TextField;
public var theWebsite:String;
public var myWebsiteLink:String;
public var myURLLoader:URLLoader= new URLLoader();
public var xmlData:XML = new XML();
public var myURLRequest:URLRequest= new URLRequest("links.xml");
public function xmlLinkLoader() {
myURLLoader.load(myURLRequest);
myURLLoader.addEventListener(Event.COMPLETE,dataOK);
}
public function dataOK(myevent:Event):void {
trace("xml loaded");
xmlData = new XML(myevent.target.data);
for (var i=0; i<xmlData.splashlink.length(); i++) {
var websiteLink = xmlData.splashlink.@theBandsWebsite;
}
populateMe();
trace(websiteLink);
}
public function populateMe() {
trace ("populated");
var theWebsite = xmlData.splashlink.@theBandsWebsite;
}
//
}
}
Document:
import xmlLinkLoader;
var myxmlLinkLoader= new xmlLinkLoader;