FreshNova - Home

Wednesday 10th of March 2010

Home Flash Tutorials How to Run Your Game From Your Server Only?
How to Run Your Game From Your Server Only? PDF Print E-mail
Written by Waleed Al Bahrawy   
Tuesday, 27 January 2009 20:06

Suppose you made your own flash game and you want to put it on the internet like everybody else. Well thats pretty easy, only people may take your game and put it on there own sites, or maybe just download it and play offline.


Well not to worry there is a pretty easy way to prevent it.

Just read on for the code and well offcourse a little explaination...

 

 Just insert the following code into your game ActionScript in the correct place as described below:

 

1
2
3
4
5
6
7
8
9
if (this.root.loaderInfo.url.indexOf("YOURSITEHERE") != -1) {
//OK THATS WHAT I WANT
}
else {
//if the game is not played from my server
//redirect the player to my site!
var myURL:URLRequest = new URLRequest("YOURSITEHERE");
navigateToURL(myURL);
}

 

Description of the code:

We are using the this.root.loaderInfo.url property that returns the full path of the SWF file, starting with http:// , so we are checking if the path of the game has your web address in it or not. It will return -1 if it doesnt and will return a positive value if it does.

LINE 1: The value is not -1, that means the game is running from your server. You can leave the body empty or add an action such as starting the game!


LINE 4: This means someone downloaded the game and running it from his server or on his computer. In this case you will need to redirect the player to the original place of the game which is your website.

 

LINES 7&8: These lines are for redirecting the player to your website

You can do this check before the game starts, if it is running from your server then start the game, otherwise dont start the game and redirect the player to your website.

Also when you publish your game out there on the internet you will also need to learn about flash games decomplation

Comments

Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Last Updated on Tuesday, 10 February 2009 10:38
 

Archive

 

Categories


Copyright © 2009 FreshNova, by Talha Kalim and Waleed Al-Bahrawy