Relative URLs in ActionScript 3

I have a flash movie using ActionScript 3 with some buttons that open links to new pages. Here is the code to redirect to a 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 the domain, but when I change it:

var request:URLRequest = new URLRequest('page2.html');

he no longer works in production. What am I missing here? I would not want to encode the entire URL into a movie.

+3
source share
3 answers

URLRequests refers to the HTML file containing them (no matter where your SWF is located), so you need to consider this. There is an optional EMBED / OBJECT attribute that you can modify to change this behavior, see here:

base -. [ ] [URL]. URL-, Flash Player. , Flash Player .

http://kb2.adobe.com/cps/127/tn_12701.html

EDIT: , URL- , , , - "www."...

+11

/page2.html

+1

/page2.html , .

, , URL-, - , .

, 4 5 , , URL- (, , ).

, ,

MakeURL()

, ​​ "page2.html", MakeURL URL, http://staging.site.com http://alpha.site.com.

, , .

URL-, . /page 2.html , .

+1
source

Source: https://habr.com/ru/post/1720245/


All Articles