Solved

Dynamically swap Flash movie without page reload

Posted on 2009-03-31
1
2,507 Views
Last Modified: 2012-05-06
Hi,
I am looking for a way to dynamically swap a Flash movie on this page: http://bcradvertising.com/33009/portfolio.html, without reloading the page.
Right now, I am using the code below, with JavaScript, but this is not working.
Thanks!
-Josh
<html>
<head>
<title>Boston Advertising & Online Marketing Agency / Baldwin/Clancy/Rogan</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<!-- Loading SWFObject from the Google repository; only works if you have an internet connection! -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>
 
<script type="text/javascript">
 
function loadSWF(url, targetID){
 
	//Check for existing SWF
	if(isObject(targetID)){
 
		//replace object/element with a new div
		replaceSwfWithEmptyDiv(targetID);
 
	}
	
	//Embed SWF
	if (swfobject.hasFlashPlayerVersion("7")) {
		
		var attributes = { data: url, width:"360", height:"250" };
		var params = {};
		var obj = swfobject.createSWF(attributes, params, targetID);
		
	}
 
}
 
 
function isObject(targetID){
 
	var isFound = false;
	var el = document.getElementById(targetID);
	
	if(el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")){
	
		isFound = true;
	
	}
	
	return isFound;
 
}
 
 
function replaceSwfWithEmptyDiv(targetID){
 
	var el = document.getElementById(targetID);
	
	if(el){
	
		var div = document.createElement("div");
	
		el.parentNode.insertBefore(div, el);
	
		//Remove the SWF
		swfobject.removeSWF(targetID);
	
		//Give the new DIV the old element's ID
		div.setAttribute("id", targetID);
		
	}
 
}
 
 
</script>
 
</head>
<div id="page">
<div id="wrap">
 
    <div id="header">
    </div>
    <div id="nav">
       <ul class="nav block">
<li><a href="index.html"><strong>Home</strong></a></li>
<li><a href="portfolio.html"><strong>Portfolio</strong></a></li>
<li><a href="about.html"><strong>About</strong></a></li>
<li><a href="#"><strong>Contact</strong></a></li>
</ul>
 
    </div>
	<div id="content">
    	<div class="row">
		<div id="main">
		<h2>Portfolio: Samples </h2>
		<p>From complete, integrated branding programs to print ads, radio, TV, brochures and the Web, we do it all.</p>
		<p>More importantly, we love what we do. And we hope that it shows.  </p>
 
		</div>
		</div>
		<hr />
		<div class="row">
			<div class="leftlist">
			<p><a href="galleries/amerlux_slides.swf" onclick="loadSWF(this.href, 'flashcontent'); return false;">Amerlux Lighting</a></p>
			<p><a href="galleries/ecsb_slides.swf" onclick="loadSWF(this.href, 'flashcontent'); return false;">East Cambridge Savings Bank</a></p>
			<p>ING</p>
 
			<p>Otherbooks</p>
			<p>The Community Bank</p>
			<p>Viaflo</p>
			<p>Erlab</p>
			</div>
			<div class="gallerycontainer">
		      	  <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','360','height','550','title','Baldwin/Clancy/Rogan Advertising Portfolio','src','galleries/amerlux_slides','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','galleries/amerlux_slides' ); //end AC code
 
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="360" height="250" title="Baldwin/Clancy/Rogan Advertising Portfolio">
              <param name="movie" value="galleries/amerlux_slides.swf" />
              <param name="quality" value="high" />
              <embed src="galleries/amerlux_slides.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="360" height="550"></embed>
      	  </object>
</noscript>
			</div>
		</div>
	</div>	
    <div id="footer">
        <p>Worldwide Headquarters: 1040 Great Plain Avenue, Needham, MA. P: 781-433-9833</p>
    </div>
  </div>
		<div id="subfooter">
 
			<div id="satellite">
			<p>Satellite offices*: Malden, Lexington, Medfield, Maynard, Boston, and Easton</p>
			</div>
			<div id="employees">
			<p>*aka employees' homes</p>
			</div>	
		</div>		
</div>

Open in new window

0
Comment
Question by:Josh Fialkoff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Josh Fialkoff earned 0 total points
ID: 24032744
I am closing this question because I have found a solution: http://www.htmlforums.com/flash-development/t-click-swap-flash-files-49372.html.

-Josh
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ckeditor not working on textarea created by javascript function 5 48
w3c parsing errors 4 36
allow link tag to be submit like form 15 60
type of website 13 53
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question