PDA

View Full Version : target swf in another html frame?


MaRcOnE
01-04-2006, 09:31 AM
i'd like to target an swf which is located in an another frame. Is this possible? If i choose the "control shockwave or flash" option in the behaviours palette i cannot select it. This only seems to be possible within one html page. Am i clear?

Love to here from someone..

Cheers,

MaRcOnE

davidj
01-04-2006, 10:27 AM
when you say target what exactly are you wanting to do

you can target any element from any frame

MaRcOnE
01-04-2006, 11:18 AM
i have a 2 frame frameset.

In the top frame is an swf.
In the bottom frame a html page.

In the bottom frame is a link. What is want to do is:

Click in the bottom frame on a link to goto , for example, frame 1 in the swf file in the top frame.


this code below does exactly that, but, this is within the same page. I want to do it in another frame:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

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')?fr ameNum:'')+')');
}
//-->
</script>
</head>

<body onLoad="MM_goToURL('top','navigatie.html');return document.MM_returnValue">



<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" name="navi" width="551" height="150" id="navi" title="navi">
<param name="movie" value="images/navigatie.swf">
<param name="quality" value="high">
<embed src="images/navigatie.swf" width="551" height="150" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="navi" swliveconnect="true"></embed>
</object>
</p>


test (#)</p>

</body>
</html>

domedia
01-04-2006, 01:39 PM
Easy answer is stop using frames.. and I'm deadly serious ;)
I don't see the javascript controlling the flash movie has an option to which window to target.

davidj
01-04-2006, 02:31 PM
ok
you can do it like this

frame1 (mainFrame) contains the movie

frame2 (controller) contains the links
==================

in mainFrame you need to write a javascript function thats going to control the movie

example...

function flashTarget(f)
{
document.movie1.GotoFrame(f);

}

i am using <span style='color:red'>f</span> to catch the frame number in an argument

movie1 = the movie id which you set in DW by selecting your movie and setting an id within the properties

==================

frame2 (controller) add your links

example...


<a href="#" onClick = "parent.mainFrame.flashTarget('0')">no1</a> |
<a href="#" onClick = "parent.mainFrame.flashTarget('1')">no2</a> |
<a href="#" onClick = "parent.mainFrame.flashTarget('2')">no3</a> |


Note:
<span style='color:red'>parent.mainFrame.flashTarget('0')</span> is sending 0. This is correct as Javascript starts counting at 0 (zero) so frame1 = 0, frame2 = 1 etc

example in zip...

davidj
01-04-2006, 02:36 PM
Addition...

you would control if the movie plays or stops or does tricks from within the movie itself by adding actionscript to the frame you goto

MaRcOnE
01-05-2006, 08:06 AM
Thank you very much! This is exaclty what i mean. Thanks alot!!

Best regards,


MarcOne

MaRcOnE
01-05-2006, 08:21 AM
thx again!

MaRcOnE
01-05-2006, 12:46 PM
Hi David

thx for your files, it really helped me out!!

but...

The target frame (with the flash file) in not parent... How can i target a specific frame without using parent?

thx alot..

davidj
01-05-2006, 12:57 PM
parent is the main window.
the frames are called within parent.
all frames are targeted using parent.

a three frame site for example....

Frame1
Frame2
Frame3

to target any frame from any frame you would use the DOM

parent.Frame1
parent.Frame2
parent.Frame3

Parent is not a variable but a reference. Everyone uses Parent

MaRcOnE
01-05-2006, 01:15 PM
that's the strange thing.. the target frame is called top

it works on Safari (osx), firefox 1.5 and on wintel machine on firefox. Explorer 6 errors message:

Object doesn't support this property or method

The strange thing is that is does work on your example...

Please have a look at the attached files..

on the homepage (the orange part) click on: Lees meer op Vraag & Antwoord

Click on the logo to return home

davidj
01-05-2006, 03:14 PM
that's the strange thing.. the target frame is called top
so why cant you reference it by...

parent.top

if my example worked then your code must be at fault

MaRcOnE
01-05-2006, 03:22 PM
strange huh? I did use parent.top

do the files that i've posted work on your IE? The do in firefox but not in IE..

davidj
01-05-2006, 03:38 PM
sussed it

you have named some frames but not all

give every frame an identifier or name

MaRcOnE
01-05-2006, 03:49 PM
*crying*..

that doesn't work either...

davidj
01-05-2006, 03:59 PM
you never gave your movie an ID in DW

if your using the example below then movie1 would be your movie id

document.movie1.gotoFrame(?)

click the movie in DW and give it a name in the properties panel

make sure that your function references that name

MaRcOnE
01-06-2006, 07:03 AM
Hi David

I've, mostly you!, fixed it.. but the problem was of a different kind. Here's the deal:

I've named my target frame "top", this doesn't seem to be allowed! I've changed the name to "test" and now it does work!!

bloody IE!

thx alot



..life is like a nose, get the most out of it..

davidj
01-06-2006, 02:11 PM
no problem

although i am now on a course of prozac thanks to your posts :blink:

Creative Insanity
01-06-2006, 04:56 PM
although i am now on a course of prozac
PMSL

postal1123
03-30-2006, 06:38 PM
Hi there,
New at this, so I'm a little bit desperate!!! Can anyone help me?
The thing is this, I want to control my flash movie doing the following thing:

<font size="1" face="Verdana">My text here (#)</font></div>

But i don't want it to just play the movie, I want it to go to a certain frame.
Is that possible? If so, please post the code. I'll be forever grateful.

Thanx
Lau

Creative Insanity
03-30-2006, 06:55 PM
postal1123, please start your own thread. It is not nice to hyjack another.