Forum Moderators: open
Flash supports javascript functions so if you encode the external URL's in javascript you can send this to flash which the actionscript can then decoded and act on.
Firstly name your movie
name="whatever" in both object and embed
put this in the ehad of the page
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
var obj=MM_findObj(objStr);
if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
}
//-->
</script>
and then this in an javascript <a href> tag
"MM_controlShockwave('whatever','','GotoFrame','9')"
It works in IE will need to test/ammend in others.
I am not absolutely sure what I am trying to send, this is partly what I am trying to find out - I am trying to tell the movie to go to a specific point from an external link
I stupidly thought I would just be able to add something to the end of a link, but i see from Richard_n's post (thank you) I am going to be putting JS in to the head area - I dont suppose you know if this can go in to an external folder, there are going to be hundreds of pages with these links in and this is going to add significant size to the site -
I thought there would be an easier way to do this..
Also I thought I read somewhere that flash can listen for instructions from outside of itself..(mmm perhaps been at the moon shine too long)
ZA
Flash can communicate with the outside world but a pure flash solution would (i think) need to be instigated by the flash file. If your trying to talk the other way you will (again i think) need a language flash and html both undestand. Javascript is probably the simplest but it could be done with PHP, ASP or Coldfusion but its likely that its a more complex solution and better suited to passing data rather than just a gotoandplay function.
If you have a different url on which the swf running for each situation, you could set something simple like:
if (this._url = "http://mydomain.com/1.html") {
//goto frame code
}
this._url is the url from which the file was downloaded.
I've never used this, but it should work. You could tack on variables on the end, too.
I dont really want to make up several versions of the flash movie, I was hoping to tackle this in the one movie - the problem was how to talk to flash externally and tell it to display specific co-ordinates in the movie - looks like I will be at this one for some time, I will try the JS method and use the include funtion for the script
thanks again - back to work
ZA
Here's what I'd try. Let's say you have a movie with 3 frames called myMovie.swf. Then you have a php page called myPage.php. And on that one page you have myMovie.swf.
Link to the page like:
/myPage.php?frame=1
/myPage.php?frame=2
/myPage.php?frame=3
Then place this actionscript in the first frame of your movie:
p = 3; //number of frames in your movie
i = 1; //counter
//loop until you find the matching url
while (i<=p) {
//set page name variable
var pageID = "http://mydomain.com/myPage.php?frame=" + i;
//check referring url
if (this._url = pageID) {
goToAndStop(i);
break;
}
i++
}
I really think this maybe the simplest solution for you. Assuming it works. Ha ha! Then there's little script to write. Your php page doesn't even need to do anything with the variable.
I haven't been writing much A.S. lately so double check my code. Let me know if you get it working.