469,330 Members | 1,212 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

how can I periodically change the flash shown?

mikek12004
200 100+
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?
Mar 11 '09 #1
17 2568
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
Mar 11 '09 #2
mikek12004
200 100+
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
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <script type="text/javascript">
  5. var int=self.setInterval("clock()",2000);
  6. function clock()
  7. {
  8. i=document.getElementById("order").value
  9. if (i=='1') text='This';
  10. else if (i=='2') text='is';
  11. else if (i=='3') text='a';
  12. else if (i=='4') text='message';
  13. if (i<4) i++;
  14. else i=1;
  15.  
  16. document.getElementById("order").value=i
  17. document.getElementById("clock").innerHTML=text
  18. return i;
  19. }
  20. </script>
  21. <h1 id='clock'>Hi to all</h1>
  22. <input type='hidden' id='order' value='1'>
  23.  
  24.  
  25. </body>
  26.  
Mar 11 '09 #3
gits
5,390 Expert Mod 4TB
how did you basicly include the flash in your html?
Mar 11 '09 #4
acoder
16,027 Expert Mod 8TB
For any JavaScript-Flash integration, I would recommend swfobject.
Mar 11 '09 #5
mikek12004
200 100+
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
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. 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
  3. </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">
  4.   <param name="movie" value="swf/logo.swf">
  5.   <param name="quality" value="high">
  6.   <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>
  7. </object>
  8. </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
Mar 12 '09 #6
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

Expand|Select|Wrap|Line Numbers
  1. var node = document.getElementById('your_id');
and then set the src:

Expand|Select|Wrap|Line Numbers
  1. node.src = 'new_swf_src.swf';
kind regards
Mar 12 '09 #7
mikek12004
200 100+
Don't I need to chance also the src in the AC_FL_RunContent (last parameter)?
Mar 12 '09 #8
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 ...
Mar 12 '09 #9
mikek12004
200 100+
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?
Mar 17 '09 #10
acoder
16,027 Expert Mod 8TB
Can you post exactly what you tried?
Mar 17 '09 #11
mikek12004
200 100+
have this which works fine
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
  3. <body>
  4.  
  5. <script type="text/javascript">
  6. var int=self.setInterval("clock()",2000);
  7. function clock()
  8. {
  9. i=document.getElementById("order").value
  10. if (i=='1') text='This';
  11. else if (i=='2') text="mike";
  12. else if (i=='3') text='a';
  13. else if (i=='4') text='message';
  14. if (i<4) i++;
  15. else i=1;
  16.  
  17. document.getElementById("order").value=i
  18. document.getElementById("clock").innerHTML=text
  19. return i;
  20. }
  21. </script>
  22. <h1 id='clock'>Hi to all
  23.   <script type="text/javascript">
  24. 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");
  25. </script>
  26. </h1>
  27. <input type='hidden' id='order' value='1'>
  28. </body>
  29. </html>
  30.  
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
May 4 '09 #12
acoder
16,027 Expert Mod 8TB
Instead of trying to insert JavaScript code, make the call to the AC_FL.. function within the function.
May 4 '09 #13
mikek12004
200 100+
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) ?
May 5 '09 #14
mikek12004
200 100+
tried this but after the 1st swf the page loads forever and donot load 2nd swf
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. </head>
  4. <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
  5. <body>
  6.  
  7. <script type="text/javascript">
  8. var int=self.setInterval("clock()",2000);
  9. function clock()
  10. {
  11. i=document.getElementById("order").value
  12. if (i=='1') 
  13. {
  14.     width='779';
  15.     height='136';
  16.     src='gmlogoA';
  17. }
  18. else if (i=='2') 
  19. {
  20.     width='779';
  21.     height='136';
  22.     src='gmlogob';
  23. }
  24. if (i<3) i++;
  25. else i=1;
  26.  
  27. document.getElementById("order").value=i
  28. 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' ); 
  29.  
  30.  
  31. return i;
  32. }
  33. </script>
  34. <span id='clock'>Hi to all
  35.  
  36. </span>
  37. <form>
  38. <input type='hidden' id='order'  name='order' value='1' />
  39. </form>
  40.  
  41. </body>
  42. </html>
  43.  
May 5 '09 #15
acoder
16,027 Expert Mod 8TB
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.
May 5 '09 #16
mikek12004
200 100+
Are you refering to some particular documentation/tutorials here in this forum (never noticed that you had any)?
May 5 '09 #17
acoder
16,027 Expert Mod 8TB
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).
May 5 '09 #18

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
reply views Thread by =?Utf-8?B?QnJpYW5ESA==?= | last post: by
reply views Thread by =?Utf-8?B?QnJpYW5ESA==?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.