View Full Version : Swap Video when Link is clicked

04-14-2009, 06:07 PM
Hey, I am trying to set up this html page so there is a default video. When the user clicks on the links below the default video that video loads in the place where the default is. (kind of like a swap). Im having a real hard time. I would appreciate any help.

Right now I have but it doesnt work:

<script type="text/javascript">
function playMovie( a, href ) {

// remove element if exists
var container = document.getElementById( "playing" );
var flash_movie = document.getElementById( "flash_movie" );

if( flash_movie ) {
container.removeChild( flash_movie );

// create new element
var embed = document.createElement( "EMBED" );
embed.setAttribute( "src",
"http://origin.eastbaymedia.com/embed/player.swf" );
embed.setAttribute( "allowFullScreen", "true" );
embed.setAttribute( "allowscriptaccess", "always" );
embed.setAttribute( "flashvars",
embed.setAttribute( "width", "500" );
embed.setAttribute( "height", "350" );

// clear out the cell
cell = a.parentNode;
cell.id = 'playing';

while( cell.hasChildNodes() ) {
cell.removeChild( cell.firstChild );

// insert the element into the cell
cell.appendChild( embed );

</script><p>&nbsp;</p><table cellspacing="5" cellpadding="3" width="200" bgcolor="#59b323" border="0"><tbody><tr><td><div id="flash_movie"><embed bgcolor="undefined" flashvars="streamer=rtmp://fms.ebmcdn.net/8004B6/origin.eastbaymedia.com&amp;duration=00:02:12&amp;file=nyls/flash/virtual_open_house/VOH_040309_HD.flv&amp;image=http://origin.eastbaymedia.com/nyls/flash/thumbnails/virtual_open_house-VOH_040309_HD.flv.png?1239309765" src="http://origin.eastbaymedia.com/embed/player.swf" allowscriptaccess="always" allowfullscreen="true" width="500" height="350"></embed></div><p><span style="font-size: 12px; color: rgb(255,255,255)"><a onClick="playMovie( this,
);" href="#">Open House Opening Video</a></span></p><p>&nbsp;</p></td></tr></tbody></table><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>

04-15-2009, 04:38 AM
Why not just make the link flash? Then when the link is clicked it will load the movie no problems. Being complicated isn't always the way to go. Believe me... My flash site I created is over 300 layers... Very complex and I confuse myself in it.

04-19-2009, 09:50 PM
Look at using ExternalInterface to have Flash and JS talk.


What you should do is have a function inside of Flash that changes the movie, and the JS only allows you to invoke that function.