I am trying to load some data from an asp page that i wrote to to provie =
data to a flash order form. I am having a bit of a problem though that i =
want to load the list boxes from the asp data. Simple enough.=20
The problem i'm having is that i was trying to load the data but the =
LoadVars hadn't finished retrieving the data before the code moved on to =
try and load the data. SO I figured i needed to build an event for my =
data loader class that would fire once the data was loaded.=20
The problem is that my custom event isnt fire and i'm not really sure =
where i went wrong. The out put from my project is below as well as the =
code from the 2 files.
Output
initialize
Start Load
InLineSuccess: true
Data: Honda~Kawasaki~Yamaha~
event fired
OrderForm.fla
var dlPrintwerxMX:DataLoader =3D new DataLoader();
var loadListener:Object =3D new Object();
loadListener.onFinishLoad =3D function(){
trace("Event " + dlPrintwerxMX.MakeList);
}
dlPrintwerxMX.addEventListener("onFinishLoad",loadListener);
dlPrintwerxMX.LoadMake();
DataLoader.as
import mx.events.EventDispatcher;
class DataLoader{
private var strMake:String =3D new String();
private var strMakeID:String =3D new String();
//create a couple of methods to use in Flash
public var addEventListener:Function;
public var removeEventListener:Function;
//create the method to trigger the event
private var dispatchEvent:Function;
function DataLoader(){
trace("initialize");
EventDispatcher.initialize(this);
}
public function get MakeList():String{
return strMake;
}
=20
function LoadMake():Void{
trace("Start Load");
var lvLoader:LoadVars =3D new LoadVars();
var fLoadSuccess:Boolean =3D new Boolean();
lvLoader.onLoad =3D function(success){
trace("InLineSuccess: " + success);
if(success){
trace("Data: " + this.make);
strMake =3D this.make;
dispatchEvent({type:"onFinishLoad"});
trace("event fired");
}
fLoadSuccess =3D success;
}
lvLoader.load("http://HADES/printwerx/data.asp");
}