Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : Can I get the current page's URL?



Jack
2/10/2004 12:25:37 PM
use _url.. trace(_url) will retrieve the URL of the SWF file

or send variables thro' the html, not foolproof, but will deter a few,

<OBJECT classid="..."
codebase="..."
id="test_url" >
<PARAM NAME=movie VALUE="test_url.swf?text1=Hello">

<EMBED src="test_url.swf?text1=Hello"
NAME="test_url"
</EMBED>
</OBJECT>

if run from your html - the variable is sent
if not - no variable received
in the swf, check for the variable, text1 == "hello"

stop();
this.onEnterFrame = function(){
if(text1 == "Hello"){
gotoAndStop("ok");
} else { gotoAndStop("stolen"); }
};

or pass the variable through javascript -

<script language = "JavaScript">
<!--
function PassFlash1(){
window.document.test_url.SetVariable("text1", "hello");
}
function PassFlash2(){
window.document.test_url.SetVariable("text2", "world");
}
//-->
</script>

</HEAD>
<BODY onLoad="PassFlash1();PassFlash2();" bgcolor="#FFFFFF">
<OBJECT...id="test_url"...
<EMBED...NAME="test_url"...

in the movie, check for the variables -

this.onEnterFrame = function(){
if(text1 == "hello" && text2 == "world"){
gotoAndStop("ok");
} else { gotoAndStop("stolen"); }
};

hth




[quoted text, click to view]

Nan R
2/10/2004 8:14:47 PM
I was wondering if there is a way to get the current page's url string via
Flash. I want to be sure my Flash file is only played on a particular
page... stop it being stolen and used elsewhere..

Any ideas?

Nan

urami_
2/11/2004 12:01:30 PM

[quoted text, click to view]

how about domain ?
host = new LocalConnection();
trace(host.domain());

you can hard code domain , check from file and compare , if the domain return different value
simply unloadmovie(_root) esle play();
Make the file goes blank if run from other domain .

example
http://www.flashfugitive.com/checkDomain.swf
try to copy from cache and upload anywhere .

Synax :

// make texfield to display results
this.createTextField("u", 1, 400, 300, 0, 0);
u.autoSize = true;
a = new TextFormat();
a.bold = true;
a.size = 40;
a.color = 0xFFFFFF;

//check host
host = new LocalConnection();
nameHere = host.domain();
Origin = "flashfugitive.com";
if (nameHere == Origin) {
u.text ="whoha... i'm home";
} else {
u.text ="booo....theif"
}
u.setTextFormat(a);
stop();


of course change my domain to yours :)


Regards


urami_*

<xmas>
http://flashfugitive.com/
</xmas>

AddThis Social Bookmark Button