This should explain how to make your movies so they can't be stolen easily by others across the web. It basicly finds the url of the site the movie is hosted on and if it doesn't match the movie shoots to a stolen frame. On that frame you can put a demo of your movie or game... or a hatefull message to the people who stole your movie. Your choice.
I use the "_url" property to find the domain name of the site the movie is on. The _url property returns a string that contains the URL of the site that the movie is hosted by. Quite useful but it returns the WHOLE PATH OF THE MOVIE! Not useful for uploading to newgrounds really... so we need to clip the URL to just the domain name.
I KNOW THIS IS LONG BUT I EXPLAIN HOW IT WORKS... I DON'T JUST GIVE THE CODE WITH NO EXPLAINATION. IT'S REALLY SIMPLE TO READ.
Start off by going to the main timeline and making two labels...
on the 2nd frame of the movie the label should be "start"
on a new frame at the end of the movie that has the stolen message, the label should be "stolen"
Create a new layer. Call this layer "Protect" or something like that.
On the layer you just made write some text saying "protect" and convert it into a MOVIE CLIP symbol.
Go to the actions for this movie clip...
Make a new onClipEvent.
What we need to do first is get everything between the "://" and the next "/" to be in the url.
We will use the "indexOf("substring", "startIndex")" method. What this does is it finds a portion of text in a string and returns a number (counting left to right) for where that piece of text starts for the first time...
The "startIndex" is optional... it is a number or variable that gives the position for the indexOf method to start from...
so...
-------------------------------
onClipEvent (enterFrame){
urlStart = _url.indexOf ("://")+3;
// this will get the beginning of the url "www.yourwebsite.com"
//this returns a value of 6... the first character in a string is aways 0.
// the first 7 spaces of a url are usually... "http://" if it's different it will be a differnet number.
urlEnd = _url.indexOf("/", urlstart);
//this will get the end of the url "www.yourwebsite.com"
//The indexOf method starts looking for "/" from the character right after "://"
//and returns the position of the NEXT "/" thus you know that the domain name is inbetween.
-------------------------------
Now we have the positon of the domain name's beginning and the postion of the end.
Basicly we just got the points where the brackets are in this link...
http://[www.yourwebsite.com]/folder/anothe
rfolder/movie.swf
so to get the domain out of there so we can use it we have to create a new string with it... lets call it domain...
----------------
//this gets all the characters between the urlStart and the urlEnd... thus the domain.
domain = _url.substring( urlStart , urlEnd );
---------------
The substring method makes a new string out of a portion of another one.
"substring( startnumber, endnumber )"
at this point we have gotten the domain name.
domain = "www.yourwebsite.com"
You COULD check that against a variable that you have set up on your website if you KNOW that the site will always start with "www." but alot of portals and sites don't work that way...
Like newgrounds... SWF files are played from "uploads.ungrounded.net"
It is a pain to go to every site you want to post your movie on and figure out what the prefix is for the portal... so fix it with this.
-----------------------
//find the last period in the domain... just in case there isn't another period in there.
LastDot = domain.lastIndexOf( "." ) -1;
//find the period before that one. if none is found this will return a -1 so we add +1.
pfixEnd = domain.lastIndexOf( "." , lastdot )+1;
//this makes the prefix drop off... and changes domain to just "yourwebsite.com"
domain = _domain.substring( pfixend , domain.length);
-----------------------
I used a new method there... "lastIndexOf("substring", "startIndex")"
Don't worry it is EXACTLY the same as "indexOf" except it reads the string RIGHT to LEFT...
Ok so now...
domain = "yourwebsite.com"
we are happy at this point... cause we are almost done...
------------------
//tell the movie what to do...
if (domain != "yourwebsite.com") {
tellTarget (_root) {
gotoAndStop ("stolen");
}
} else {
if (_root._currentframe <= 1){
tellTarget (_root) {
gotoAndPlay ("start");
}
}
}
------------
Sigh... that will work I think... remember tellTarget IS DEPRICIATED if you have MX. which most of you do... I am just an old school hold out for Flash 5.
I hope this helps you all... took me a while to write it. I know it's long but it's REALLY SIMPLE.
Thanks for reading this.
WHOLE CODE:
--------------------------
onClipEvent (enterFrame) {
// get everything between the "://" and the next "/"
urlStart = _url.indexOf( "://" )+3;
urlEnd = _url.indexOf( "/", urlStart );
domain = _url.substring( urlStart, urlEnd );
// get rid of any prefixes before the second to last "."
LastDot = domain.lastIndexOf( "." ) -1;
pfixEnd = domain.lastIndexOf( "." , LastDot ) +1;
domain = domain.substring( pfixEnd , domain.length);
//tell the movie what to do...
if (domain != "yourwebsite.com") {
tellTarget (_root) {
gotoAndStop ("stolen");
}
} else {
if (_root._currentframe <= 1){
tellTarget (_root) {
gotoAndPlay ("start");
}
}
}
}
---------------------