


January 26, 2015 – How to avoid external link blocking
Hello guys, today I decided to write an article about external link blocking and how to protect your flash game from websites blocking outgoing links. This tutorial is only for Actionscript 3.
In case you don't know, all developers creating free games profit from advertisings inside the game, but mostly gaming websites are starting to block outgoing links and using these flash games without permission, if they block outgoing links, the developer will no longer profit from the game anymore, some developers use the "more games" button to redirect players to their websites too, if a gaming website blocks outgoing links, the "more games" button will no longer work.
So, how to protect my game from gaming websites blocking external outgoing links?
1) Create the movieclip that will be called when the script detects the link blocking, this movieclip will be called: mcError
2) Create a button to visit an external link to test, our button will be called: button1
3) Use the code below:
var checkNetwork:Object;
function Website(event:MouseEvent):void {
try{
checkNetwork = ExternalInterface.call(null);
navigateToURL(new URLRequest("https://www.playgb.com"));
}
catch( $e:* ){
mcError.x = 0;
mcError.y = 0;
}
}
button1.addEventListener(MouseEvent.CLICK, Website);
Make sure to put mcError in the stage but offscreen (example: x = -900, y = -900), so, when detecting the link blocking, we make the mcError appears by setting x and y to 0.
Let's test now this code, and you can download the complete source code below with all buttons and movieclips.
In the example below, we blocked the outgoing links from the .swf file by changing some flash parameters, click in the visit website button below to test:
So, we changed now the flash parameters to allow external outgoing links (default), click in the visit website button below to test:
Download complete source code
In case you don't know, all developers creating free games profit from advertisings inside the game, but mostly gaming websites are starting to block outgoing links and using these flash games without permission, if they block outgoing links, the developer will no longer profit from the game anymore, some developers use the "more games" button to redirect players to their websites too, if a gaming website blocks outgoing links, the "more games" button will no longer work.
So, how to protect my game from gaming websites blocking external outgoing links?
1) Create the movieclip that will be called when the script detects the link blocking, this movieclip will be called: mcError

2) Create a button to visit an external link to test, our button will be called: button1

3) Use the code below:
var checkNetwork:Object;
function Website(event:MouseEvent):void {
try{
checkNetwork = ExternalInterface.call(null);
navigateToURL(new URLRequest("https://www.playgb.com"));
}
catch( $e:* ){
mcError.x = 0;
mcError.y = 0;
}
}
button1.addEventListener(MouseEvent.CLICK, Website);
Make sure to put mcError in the stage but offscreen (example: x = -900, y = -900), so, when detecting the link blocking, we make the mcError appears by setting x and y to 0.
Let's test now this code, and you can download the complete source code below with all buttons and movieclips.
In the example below, we blocked the outgoing links from the .swf file by changing some flash parameters, click in the visit website button below to test:
So, we changed now the flash parameters to allow external outgoing links (default), click in the visit website button below to test:
Download complete source code
© PlayGB.com - Free online games - Blog
