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
More Articles
- Simple steps to protect your wordpress
- Blocking your flash game in some domain
- How to create a button in AS3
- Migrating from AS2 to AS3, EnterFrame Event
- gotoAndPlay Inside MovieClip AS 3.0
- Road Rash Jailbreak
- Blinded and Droid Team featured on Newgrounds!
- Dodge Copter in the first page of UOL!
- HTML5 Tutorial Getting started
- We joined Capcom Unity
Play GB – Free Games 
PlayGB also known as Play GB is a website focused in the development of free online games where you can play in your browser, you don't need to download or install anything to play a web game, the only requirement is: Flash Player. If you like to play free online flash games, you are in the right place, follow us to get always our latest releases.
PlayGB.com - Free online games
