CORS, Absolute URL and CDN

Discussion and feedback on Construct 2

Post » Thu Aug 21, 2014 2:00 am

I created some games in Construct, and they share the content.

What I want to do is to put the absolute URL to the images and the media in the exporter, and all of the images instances to have this parameter set image.crossOrigin = "anonymous";

this way I could cache the content much easier and publish much faster, now I have to publish and open the files to change all of the links
B
5
S
1
Posts: 11
Reputation: 422

Post » Sun Aug 24, 2014 8:17 pm

I created some Regular expressions to change the exported script, if anyone have the same problem


search "^(.*)var (.*) = new Image\\(\\)\\;",
replace "$1var $2 = new Image()/**/;\r\n$1$2.crossOrigin = 'anonymous';"
search "^(.*) = new Image\\(\\)\\;",
replace "$1 = new Image()/**/;\r\n$1.crossOrigin = 'anonymous';"
search "\"images/",
replace "\"http://your url here/images/"
search "\"media/",
replace "\"http://your url here/media/"

you can change the http:// to // if you want to work in both http and https, but I haven't tested yet
B
5
S
1
Posts: 11
Reputation: 422


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 18 guests