I have a flash movie using Actionscript 3 with some buttons that open links to new pages. Here is the code I have for redirecting to the new page:
myButton.addEventListener(MouseEvent.CLICK, function(e:MounseEvent) {
var request:URLRequest = new URLRequest('http://www.example.com/page2.html');
navigateToURL(request, "_top");
});
It works fine on my production server with the full url including domain, but when I change it to this:
var request:URLRequest = new URLRequest('page2.html');
it no longer works in production. What am I missing here? I would like to not have to encode the entire URL into the movie.
URLRequests are relative to the HTML file containing them (it doesn't matter where your SWF is), so you need to take that into account. There is an optional attribute of the EMBED/OBJECT that you can set to change this behaviour, see here:
base - . or [base directory] or [URL]. Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.
http://kb2.adobe.com/cps/127/tn_12701.html
EDIT: Also, try to avoid using absolute URLs for relative files, as you could get sandbox errors, for instance, loading the web without "www."...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With