I have a Flash object running on an (online) webpage that imports an AS file like so:
[AS]import load_background.lb;
var loadbackground:lb = new lb;
this.addChild (loadbackground.load_background(this.loaderInfo.parameters.time_of_day));[/AS]
To clarify, the load_background function returns a background image based a ‘time of
day’ variable given in FlashVars. This image is an absolute address, based on a root directory given as a variable in the function.
Here’s the AS:
[AS]// Add background depending on var given.
package load_background {
public class lb {
import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.DisplayObject;
public function load_background (time_of_day:String):DisplayObject {
var rootpath:String = ‘http://www.domain.com/dir/’;
var background_path:String = rootpath + ‘template/pics/’ + time_of_day + ‘/flashbg.jpg’;
var request:URLRequest = new URLRequest(background_path);
var loader:Loader = new Loader;
loader.load (request);
var bgimage:DisplayObject = loader;
return bgimage;
}
}
}[/AS]
(domain.com/dir above substitutes the actual web address since I don’t want to share the work yet.)
Now this works fine on my own computer, but on no other computers I run it on. Upon investigating the issue in Safari, I find this is because, for some reason, and despite the domain being correctly set in the rootpath variable, it loads the background image from my local testing server.
http://www.domain.com/dir/content/movie.swf?time_of_day=day
> http://localhost/dir/template/pics/day/flashbg.jpg
If I change the background_path string so that it should attempt to load a totally random and nonexistent file, it still loads the same file from my local server. If, for instance, I change rootpath so that it is http://www.domain.com/dir/********.jpg, it STILL attempts to load http://localhost/dir/template/pics/day/flashbg.jpg. WHAT??
It appears that the Flash movie is completely ignoring my AS file; I don’t understand why. This can’t possibly make sense since it requires the AS file in the first place to load any image. I honestly cannot in the slightest fathom what the **** is wrong with this. ANYTHING anyone can contribute that sheds light on the matter would be unquantifiably appreciated.