By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,735 Members | 1,286 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,735 IT Pros & Developers. It's quick & easy.

How to dynamically change a flash movie?

P: 9
Hi all,

I want to dynamically change a flash movie in an html page. Following
code is working fine in IE, but netscape 4 and 6 it is not working.
Can any one rectify the error:

<HTML>
<HEAD>
<script>
function changeFlash(url){
var d=document;
(d.all)? d.all("flashMov1").movie = url :
d.embeds["flashMov2"].src = url;
}
</script>
</HEAD>

<BODY>
<object id=flashMov1
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
width="200" height="150">
<param name="movie" value="f1.swf">
<param name="quality" value="high">

<EMBED name=flashMov2 src="f1.swf" quality=high
WIDTH="200" HEIGHT="150"
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</object>
<p></p>
<p><a href="javascript: changeFlash('f1.swf')">One </a></p>
<p><a href="javascript: changeFlash('f2.swf')">Two</a></p>
<p><a href="javascript: changeFlash('f3.swf')">Three</a></p>
(from http://www.thescripts.com/forum/thread92820.html)

I am facing the above same problem!

Can somebody help?

Thanks in advance!
Feb 16 '07 #1
Share this Question
Share on Google+
2 Replies

acoder
Expert Mod 15k+
P: 16,027
Don't use document.all to detect IE. Give the object an id and use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(id).src=url;
and in IE, use the movie parameter to change the source (as you are already doing).
Feb 16 '07 #2

acoder
Expert Mod 15k+
P: 16,027
What you use depends on whether you use OBJECT or EMBED for your flash player. See this link for all the options.

Also, you might consider using SWFObject for detect and embed your Flash Player.
Feb 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.