Forum Moderators: open

Message Too Old, No Replies

Link from External HTML page into .swf

         

zackattack

5:22 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



Hi

I am trying to find a simple way to get an external link (outside my movie) to link into a specific frame or point in my movie

Is there any way to do this?

I would imagine it would be a variable being sent in to the flash movie, just not sure how..

any help would be much appreciated

ZA

4string

8:25 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



You could send post or get variables from your page to the swf. Look up loadVariables() in the help file. Then you'll have to write a little AS like gotoframe(my_var).

zackattack

9:28 pm on Jun 19, 2005 (gmt 0)

10+ Year Member



I will have a look at loadvariables,
have you done this sort of thing before?
can you give me an example of what an external link sending information in to flash would look like, this would give me a starter

ZA

4string

1:06 am on Jun 20, 2005 (gmt 0)

10+ Year Member



I usually load variables from a txt file. I'm sure it's much the same process from a script. What are you trying to send?

Richard_N

7:17 am on Jun 20, 2005 (gmt 0)



your surely going to have to set up commuication from the HTML link, to the flash file, and then get the flash file to react according to what you send..

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.

Richard_N

7:52 am on Jun 20, 2005 (gmt 0)



OK did a bit of checking, there is actually a javascript behaviour built into dreamweaver..

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.

zackattack

8:18 am on Jun 20, 2005 (gmt 0)

10+ Year Member



Thanks very much for the responses

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

Richard_N

10:45 am on Jun 20, 2005 (gmt 0)



yes you can put the JS in an external js file and call it into the head element the same way you do an external css file, if its a case of so many pages you could make a header and footer file seperate from the main content and just do a <php include> that way you alter one file and it reflects across the whole site.

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.

4string

1:21 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



Just an idea...

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.

zackattack

3:05 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



Thank you for your suggestions

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

4string

4:12 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



That's what I'm saying -- one movie on different urls. If you put that actionscript in there it would go to the correct frame in your movie depending on the movie's location.

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.

zackattack

12:13 pm on Jun 24, 2005 (gmt 0)

10+ Year Member



Thanks for your time 4String I will give this a whirl

ZA