I am struggling with this bit of code
var bgimage:String = new String();
var myTextLoader:URLLoader = new URLLoader();
myTextLoader.dataFormat=URLLoaderDataFormat.VARIAB LES;
myTextLoader.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {
bgimage = e.target.data.bg;
trace(bgimage);
}
myTextLoader.load(new URLRequest(“background.txt”));
var imageLoader:Loader;
function loadImage(url:String):void {
// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(Pro gressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, imageLoaded);
}
loadImage(bgimage);
function imageLoaded(e:Event):void {
// Load Image
imageArea.addChild(imageLoader);
}
function imageLoading(e:ProgressEvent):void {
// Use it to get current download progress
// Hint: You could tie the values to a preloader
}
The Code fetches data from a text file and stores it in variable bgimage. On executing this piece of Code, I am getting the following error
“image1.png”
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
The trace(bgimage) gives the correct value of bgimage but when bgimage is passed as an arguement to loadMovie (finally to URLRequst) , the above error is shown.
However when I replace loadImage(bgimage); by loadImage(“image1.png”); it works perfectly. Just unable to make out why it isn’t taking a variable as an arguement but a direct value works perfectly.
Waiting for a solution to the problem desperately.
Thanks