Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Javascript and flash

Question posted by: th1982 (Member) on February 28th, 2008 09:20 AM
Now I have 3 flash movies.I want to create a dropdown menu to select what movie i want to play.And the movie will be played below of menu.any solution for it
thanks
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
gits's Avatar
gits
Moderator
3,082 Posts
February 28th, 2008
10:47 AM
#2

Re: Javascript and flash
hi ...

please show the code you already have ...

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
February 29th, 2008
01:53 AM
#3

Re: Javascript and flash
Here is the Code:

Code: ( text )
  1. <style type="text/css">
  2. <!--
  3. .style20 {font-size: 9px}
  4. -->
  5. </style>
  6. <!--
  7. <SCRIPT LANGUAGE="JavaScript"
  8. TYPE="text/javascript">
  9. funtion change(){
  10. video = new Array()
  11. for(i=0;i<3;i++)
  12. {
  13. video[i] = new Video()
  14. video[i].src = "flash/video" + i + ".swf"
  15. }
  16.  
  17. window.onerror = null;}
  18. //-->
  19. </SCRIPT>
  20. <table border="0" cellspacing="2">
  21.    <tr><br /><br /><br /><br /><br /><br /></tr> <tr>
  22.     <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9">
  23.         <tr>
  24.           <td><img src="img/latest news.jpg" alt="ee" width="41" height="34" /></td>
  25.           <td style="padding-left:15px;"><p align="left"><span class="style20"><strong>Lastest News</strong> |
  26.             Download here</span> </p></td>
  27.         </tr>
  28.     </table></td>
  29.   </tr>
  30.   <tr>
  31.     <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9">
  32.         <tr>
  33.           <td width="41"><a href="index.php?l1=161&l2=171"><img src="img/careers.jpg" alt="ee" width="41" height="34" border="0" /></a></td>
  34.           <td style="padding-left:15px;"><a href="index.php?l1=161&l2=171" class="tablink"><b>Career</b> |  Apply now!</a></td>
  35.         </tr>
  36.     </table></td>
  37.   </tr>
  38.   <tr>
  39.     <td ><table width="100%" border="0" cellpadding="3">
  40.       <tr>
  41.           <td>Video</td>
  42.           <td><select name="select" id=numpage onChange="change()">
  43.            
  44.               <option value="0">VFM - ad</option>
  45.                 <option value="1">VFM - Introduction</option>
  46.                 <option value="2">VFM - VietNam: The potential market</option>
  47.           </select>
  48.             </td>
  49.       </tr>
  50.       </table>
  51.     <param name="quality" value="high" />
  52.     <embed src="flash/video0.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="270" height="250"></embed>
  53.     </tr>
  54. </table>


Thanks

Last edited by gits : February 29th, 2008 at 06:45 AM. Reason: added code tags
Reply
gits's Avatar
gits
Moderator
3,082 Posts
February 29th, 2008
06:54 AM
#4

Re: Javascript and flash
hi ...

first give your embed-node an id:

Code: ( text )
  1. id="video_container"

second chnage the change-function to this:

Code: ( text )
  1. funtion change(node) {
  2.     var video = document.getElementById('video_container');
  3.     video[i].src = "flash/video" + node.value + ".swf";
  4. }

last - call the function like this:

Code: ( text )
  1. <select name="select" id="numpage" onchange="change(this);">

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 1st, 2008
05:32 PM
#5

Re: Javascript and flash
am i correct with this?Thanks yo yr help
Code: ( text )
  1. <style type="text/css">
  2. <!--
  3. .style20 {font-size: 9px}
  4. -->
  5. </style>
  6. <!--
  7. <SCRIPT LANGUAGE="JavaScript"
  8. TYPE="text/javascript">
  9. funtion change(node) {
  10.     var video = document.getElementById('video_container');
  11.     video[i].src = "flash/video" + node.value + ".swf";
  12. }
  13.  
  14. //-->
  15. </SCRIPT>
  16. <table border="0" cellspacing="2">
  17.    <tr><br /><br /><br /><br /><br /><br /></tr> <tr>
  18.     <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9">
  19.         <tr>
  20.           <td><img src="img/latest news.jpg" alt="ee" width="41" height="34" /></td>
  21.           <td style="padding-left:15px;"><p align="left"><span class="style20"><strong>Lastest News</strong> |
  22.             Download here</span> </p></td>
  23.         </tr>
  24.     </table></td>
  25.   </tr>
  26.   <tr>
  27.     <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9">
  28.         <tr>
  29.           <td width="41"><a href="index.php?l1=161&l2=171"><img src="img/careers.jpg" alt="ee" width="41" height="34" border="0" /></a></td>
  30.           <td style="padding-left:15px;"><a href="index.php?l1=161&l2=171" class="tablink"><b>Career</b> |  Apply now!</a></td>
  31.         </tr>
  32.     </table></td>
  33.   </tr>
  34.   <tr>
  35.     <td ><table width="100%" border="0" cellpadding="3">
  36.       <tr>
  37.           <td>Video</td>
  38.           <td><select name="select" id=numpage onChange="change(this)">
  39.            
  40.               <option value="0">VFM - ad</option>
  41.                 <option value="1">VFM - Introduction</option>
  42.                 <option value="2">VFM - VietNam: The potential market</option>
  43.           </select>
  44.             </td>
  45.       </tr>
  46.       </table>
  47.     <param name="quality" value="high" />
  48.     <embed id="video_container"
  49.  src="flash/video0.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="270" height="250"></embed>
  50.     </tr>
  51. </table>

Reply
th1982's Avatar
th1982
Member
50 Posts
March 3rd, 2008
04:07 AM
#6

Re: Javascript and flash
Like the code above ,it dosen't work
another way to do it.thanks for supporting.

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 3rd, 2008
07:53 AM
#7

Re: Javascript and flash
do you get any errors? btw. please set the id-name of your select-node in quotes like all attributes of a node has to be in quotes ... (onclick, id, readonly etc.)

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 3rd, 2008
09:25 AM
#8

Re: Javascript and flash
You can take a look to this link :
http://www.purpleasia.com/clients/V...ndex.php?l1=161
it's not effected.
thanks

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 3rd, 2008
12:36 PM
#9

Re: Javascript and flash
ahhhrg :) ... sorry ... my bad i gave you the following line:

Code: ( text )
  1. video[i].src = "flash/video" + node.value + ".swf";

just use:

Code: ( text )
  1. video.src = "flash/video" + node.value + ".swf";

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 3rd, 2008
05:10 PM
#10

Re: Javascript and flash
Still not working.Even I changed to this :
Code: ( text )
  1. <style type="text/css">
  2.  
  3.  
  4.  
  5. .style20 {font-size: 9px}
  6.  
  7.  
  8.  
  9. </style>
  10.  
  11.  
  12.  
  13. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  14. function change(node) {
  15.  
  16. var video = document.getElementById('video_container');
  17.  
  18. video.src = "flash/video" + node.value + ".swf";
  19.  
  20. }
  21.  
  22.  
  23. </SCRIPT>
  24.  
  25. <table border="0" cellspacing="2">
  26.  
  27. <tr><br /><br /><br /><br /><br /><br /></tr> <tr>
  28.  
  29. <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9">
  30.  
  31. <tr>
  32.  
  33. <td><img src="img/latest news.jpg" alt="ee" width="41" height="34" /></td>
  34.  
  35. <td style="padding-left:15px;"><p align="left"><span class="style20"><strong>Lastest News</strong> |
  36.  
  37. Download here</span> </p></td>
  38.  
  39. </tr>
  40.  
  41. </table></td>
  42.  
  43. </tr>
  44.  
  45. <tr>
  46.  
  47. <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9">
  48.  
  49. <tr>
  50.  
  51. <td width="41"><a href="index.php?l1=161&l2=171"><img src="img/careers.jpg" alt="ee" width="41" height="34" border="0" /></a></td>
  52.  
  53. <td style="padding-left:15px;"><a href="index.php?l1=161&l2=171" class="tablink"><b>Career</b> | Apply now!</a></td>
  54.  
  55. </tr>
  56.  
  57. </table></td>
  58.  
  59. </tr>
  60.  
  61. <tr>
  62.  
  63. <td ><table width="100%" border="0" cellpadding="3">
  64.  
  65. <tr>
  66.  
  67. <td>Video</td>
  68.  
  69. <td><select name="select" id="numpage" onchange="change(this);">
  70.  
  71.  
  72.  
  73. <option id="0" value="0">VFM - ad</option>
  74.  
  75. <option id="1" value="1">VFM - Introduction</option>
  76.  
  77. <option id="2" value="2">VFM - VietNam: The potential market</option>
  78.  
  79. </select>
  80.  
  81. </td>
  82.  
  83. </tr>
  84. </table>
  85.  
  86. <param name="quality" value="high" />
  87.  
  88. <embed id="video_container" src="flash/video0.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="270" height="250"></embed>
  89.  
  90. </tr>
  91.  
  92. </table>

Reply
th1982's Avatar
th1982
Member
50 Posts
March 5th, 2008
04:18 PM
#11

Re: Javascript and flash
pls help!!!
have any solutions for this?
thanks alot

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 6th, 2008
08:00 AM
#12

Re: Javascript and flash
hi ...

may be we have to rewrite the entire embed-node ... so try this:

Code: ( text )
  1. function change(node) {
  2.     var video   = document.getElementById('video_container');
  3.     var n_video = video.cloneNode(true);
  4.    
  5.     n_video.src = "flash/video" + node.value + ".swf";
  6.  
  7.     video.parentNode.replaceChild(n_video, video);
  8. }

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 7th, 2008
09:04 AM
#13

Re: Javascript and flash
Finnaly , it's worked.Thanks alot gits.Pls help me next time
best regards.

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 7th, 2008
09:09 AM
#14

Re: Javascript and flash
no problem :) ... thats the purpose of this forum :D ... so post back to the forum anytime you have more questions ...

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 27th, 2008
05:23 AM
#15

Re: Javascript and flash
Hi gits
i have problem when i run this script in IE:http://www.purpleasia.com/clients/V...ndex.php?l1=161
FF is no problem
why is it?thanks so much

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 27th, 2008
07:21 AM
#16

Re: Javascript and flash
i don't have an IE (mac-user ;) ) ... so what is not working ... do you get an error?

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 27th, 2008
08:26 AM
#17

Re: Javascript and flash
oh sorry!
only first clip can run,second and third clips are not disappeared
and select box very small , i can only see "V"character(in FF i can see the full text inside the select box).
thanks to yr answer.

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 27th, 2008
09:37 AM
#18

Re: Javascript and flash
hmmm ... the selectbox issue comes from you selects css style - just remove it to see the effect ...

the other issue with the replacing of the nodes ... seems to be an IE bug (look here ) and may be you should replace the embed with the object tag - which is the w3c standards-compliant way to embed flash ... have a look at the link in the answers at quirksmode.org (i mean this one) ...

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 28th, 2008
07:18 AM
#19

Re: Javascript and flash
Thanks very much!!!
I've tried to put it in 2 ways like this :
First :
Code: ( text )
  1. <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  2. codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
  3. WIDTH="204" HEIGHT="183" id="video_container"><PARAM NAME=movie VALUE="flash/video0.swf"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="flash/video0.swf" quality=high bgcolor=#FFFFFF WIDTH="204" HEIGHT="183"
  4. NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"
  5. PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>


Second :

Code: ( text )
  1. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"" width="204" height="183" id="video_container"><param name="movie"  value="flash/video0.swf" /> <param name="quality" value="high" /> </object>


Results : FF and IE : only play video0.swf which we put in the code.
are anything wrong from these code?

Thanks
best regards

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 28th, 2008
07:34 AM
#20

Re: Javascript and flash
... and you have to change the javascript function too ... since the movie-src is now defined in the param-node ...

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 28th, 2008
08:20 AM
#21

Re: Javascript and flash
the function will be like this ,am i right?

Code: ( text )
  1. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  2.    
  3.       function change(node) {
  4.  
  5.           var movie   = document.getElementById('video_container');
  6.       var n_movie = movie.cloneNode(true);
  7.  
  8.          
  9.  
  10.           n_movie.value= "flash/video" + node.value + ".swf";
  11.    
  12.        
  13.    
  14.           movie.parentNode.replaceChild(n_movie, movie);
  15.  
  16.       }
  17.  
  18.  
  19.       </SCRIPT>

Reply
gits's Avatar
gits
Moderator
3,082 Posts
March 28th, 2008
04:01 PM
#22

Re: Javascript and flash
nope ... that should have worked with the 'embed-version' ... :)

try this:

Code: ( text )
  1. function change(node) {
  2.     var video = document.getElementById('video_container');
  3.     var o_param = video.getElementsByTagName('param')[0];
  4.     var n_param = o_param.cloneNode(true);
  5.    
  6.     n_param.setAttribute('value', 'flash/video' + node.value + '.swf');
  7.  
  8.     n_param.parentNode.replaceChild(n_param, o_param);
  9. }

kind regards

Reply
th1982's Avatar
th1982
Member
50 Posts
March 29th, 2008
06:17 PM
#23

Re: Javascript and flash
i changed the code like this :

Code: ( text )
  1. <!--<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  2.    
  3.       function change(node) {
  4.     var video   = document.getElementById('video_container');
  5.     var n_video = video.cloneNode(true);
  6.    
  7.     n_video.src = "flash/video" + node.value + ".swf";
  8.  
  9.     video.parentNode.replaceChild(n_video, video);
  10. }
  11.  
  12.  
  13.  
  14.       </SCRIPT>-->
  15. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  16. function change(node) {
  17.     var video = document.getElementById('video_container');
  18.     var o_param = video.getElementsByTagName('param')[0];
  19.     var n_param = o_param.cloneNode(true);
  20.    
  21.     n_param.setAttribute('value', 'flash/video' + node.value + '.swf');
  22.  
  23.    o_param.parentNode.replaceChild(n_param, o_param);
  24. }
  25.  
  26.   </SCRIPT>
  27.       <table>
  28.          <tr>
  29.  
  30.           <td style="padding-left:0px;"><table width="200" border="0" cellpadding="0" cellspacing="0">
  31.  
  32. <tr>
  33.                 <td><img src="img/latestnews.gif" width="204"></td>
  34. </tr>
  35.  
  36.           </table></td>
  37.  
  38.         </tr>
  39.  
  40.         <tr>
  41.  
  42.           <td style="padding-left:0x;"><table width="200" border="0" cellpadding="0" cellspacing="0">
  43.  
  44. <tr>
  45.  
  46.                <td><img src="img/career-icon.gif" width="204" border="0"></td>
  47.  
  48.             </tr>
  49.  
  50.           </table></td>
  51.  
  52.         </tr>
  53.  
  54. <table>
  55.   <tr>
  56.  
  57.           <td  align="right" bgcolor="#cacfd0"><table width="100%" border="0" cellpadding="3">
  58.  
  59. <tr>
  60.           
  61.                 <td>Video</td>
  62.  
  63.                 <td><select name="select"   style="width:140px;" onchange="change(this);">
  64.  
  65.                  
  66.  
  67.                     <option   id="0"   value="0">VFM - ad</option>
  68.  
  69.                       <option id="1" value="1">VFM - Introduction</option>
  70.  
  71.                       <option id="2" value="2">VFM - VietNam: The potential market</option>
  72.  
  73.                 </select>
  74.  
  75.           </td>
  76.  
  77.             </tr>
  78.             </table>
  79.  
  80. <!--<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  81. codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
  82. WIDTH="204" HEIGHT="183" id="video_container"><param name="movie" value="flash/video0.swf" /><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="flash/video0.swf"  id="video_container" quality=high bgcolor=#FFFFFF WIDTH="204" HEIGHT="183"
  83. NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"
  84. PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></tr></table>
  85. <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  86. codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
  87. WIDTH="204" HEIGHT="183"><param    name="quality" value="high" />
  88.         <embed src="flash/video0.swf" width="204" height="183" loop="false" align="right"  id="video_container" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" AUTOPLAY="FALSE" play="false"></embed>  </object>    -->
  89.  
  90. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"" width="204" height="183"  id="video_container"><param name="movie"   value="flash/video0.swf" /> <param name="quality" value="high" /> </object>
  91.     </tr></table>


but the video's disappeared in FF , and in IE ,video0 appear but can not change to the others

Reply