Most of you must have seen a flash which after a period of time is replaced by another flash, which in turn is replaced by another flash etc. how to this?
17 2609 gits 5,390
Expert Mod 4TB
you may use JavaScripts setInterval() method to call a function that periodically changes the src/value for the respective embed/object tags to new values ...
kind regards
OK this is the code which works fine replacing text in a div; how it can be mod to replace flash?tried to put into the text variable what I would put in the HTML to display the flash but didn't work -
<html>
-
<body>
-
-
<script type="text/javascript">
-
var int=self.setInterval("clock()",2000);
-
function clock()
-
{
-
i=document.getElementById("order").value
-
if (i=='1') text='This';
-
else if (i=='2') text='is';
-
else if (i=='3') text='a';
-
else if (i=='4') text='message';
-
if (i<4) i++;
-
else i=1;
-
-
document.getElementById("order").value=i
-
document.getElementById("clock").innerHTML=text
-
return i;
-
}
-
</script>
-
<h1 id='clock'>Hi to all</h1>
-
<input type='hidden' id='order' value='1'>
-
-
-
</body>
-
gits 5,390
Expert Mod 4TB
how did you basicly include the flash in your html?
For any JavaScript-Flash integration, I would recommend swfobject.
I use the standard code produced by dreamweaver. In the place you wish the flash to appear choose (Insert->media->flash) and he program produce the following code -
<script type="text/javascript">
-
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','468','height','60','src','swf/logo','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','swf/logo' ); //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=9,0,28,0" width="468" height="60">
-
<param name="movie" value="swf/logo.swf">
-
<param name="quality" value="high">
-
<embed src="swf/logo.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60"></embed>
-
</object>
-
</noscript>
As I have seen the AC_FL_RunContent function alone do the work just fine the noscript tag exists for older browsers who do not support the above function
gits 5,390
Expert Mod 4TB
in this case you need to retrieve the first param-node and the embed-node and change its src-attribute ... give them different id-attribs and retrieve them with - var node = document.getElementById('your_id');
and then set the src: - node.src = 'new_swf_src.swf';
kind regards
Don't I need to chance also the src in the AC_FL_RunContent (last parameter)?
gits 5,390
Expert Mod 4TB
ahh ... i just overlooked that ... of course ... but then you just need to call the method with the other parameter again ...
well tried that and the default banner changes ok but then the 2nd one do not and the page loads forever hmm....do you know if something like this already exists or how to search for it?
Can you post exactly what you tried?
have this which works fine -
<html>
-
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
-
<body>
-
-
<script type="text/javascript">
-
var int=self.setInterval("clock()",2000);
-
function clock()
-
{
-
i=document.getElementById("order").value
-
if (i=='1') text='This';
-
else if (i=='2') text="mike";
-
else if (i=='3') text='a';
-
else if (i=='4') text='message';
-
if (i<4) i++;
-
else i=1;
-
-
document.getElementById("order").value=i
-
document.getElementById("clock").innerHTML=text
-
return i;
-
}
-
</script>
-
<h1 id='clock'>Hi to all
-
<script type="text/javascript">
-
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','779','height','136','src','gmlogoA','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','gmlogoA' ); //end AC code");
-
</script>
-
</h1>
-
<input type='hidden' id='order' value='1'>
-
</body>
-
</html>
-
problem is that I want instead of letters which are in the text variable of the clock() to put a flash like I did manually in <h1>, tried to put it in the text but finds the ending script tag and ignores rest of javascript any help
Instead of trying to insert JavaScript code, make the call to the AC_FL.. function within the function.
how exactly can I call the AC_FL.. function and have the flash to appear inside the h1 tag (or any other area I put e.g with a span) ?
tried this but after the 1st swf the page loads forever and donot load 2nd swf -
<html>
-
<head>
-
</head>
-
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
-
<body>
-
-
<script type="text/javascript">
-
var int=self.setInterval("clock()",2000);
-
function clock()
-
{
-
i=document.getElementById("order").value
-
if (i=='1')
-
{
-
width='779';
-
height='136';
-
src='gmlogoA';
-
}
-
else if (i=='2')
-
{
-
width='779';
-
height='136';
-
src='gmlogob';
-
}
-
if (i<3) i++;
-
else i=1;
-
-
document.getElementById("order").value=i
-
document.getElementById("clock").innerHTML=AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','779','height','136','src','gmlogoA','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','gmlogoA' );
-
-
-
return i;
-
}
-
</script>
-
<span id='clock'>Hi to all
-
-
</span>
-
<form>
-
<input type='hidden' id='order' name='order' value='1' />
-
</form>
-
-
</body>
-
</html>
-
I would recommend, as I have done earlier, that you go with swfobject. It should be more reliable and easier to work with than the AC_FL code. Also check out the tutorials/documentation.
Are you refering to some particular documentation/tutorials here in this forum (never noticed that you had any)?
No, I meant in the swfobject link (Getting Started). There are some tutorials/articles in the insights section, but not for what you want (currently anyway).
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
6 posts
views
Thread by Gustav Medler |
last post: by
|
1 post
views
Thread by Bruce W.1 |
last post: by
|
2 posts
views
Thread by Yash |
last post: by
|
8 posts
views
Thread by Neo Geshel |
last post: by
|
reply
views
Thread by =?Utf-8?B?QnJpYW5ESA==?= |
last post: by
|
reply
views
Thread by =?Utf-8?B?QnJpYW5ESA==?= |
last post: by
| | | | | | | | | | | | | |