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).
|
|
February 28th, 2008 10:47 AM
# 2
|
Re: Javascript and flash
hi ...
please show the code you already have ...
kind regards
|
|
February 29th, 2008 01:53 AM
# 3
|
Re: Javascript and flash
Here is the Code:
Code: ( text )
<style type="text/css"> <!-- .style20 {font-size: 9px} --> </style> <!-- <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> funtion change(){ video = new Array() for(i=0;i<3;i++) { video[i] = new Video() video[i].src = "flash/video" + i + ".swf" } window.onerror = null;} //--> </SCRIPT> <table border="0" cellspacing="2"> <tr><br /><br /><br /><br /><br /><br /></tr> <tr> <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9"> <tr> <td><img src="img/latest news.jpg" alt="ee" width="41" height="34" /></td> <td style="padding-left:15px;"><p align="left"><span class="style20"><strong>Lastest News</strong> | Download here</span> </p></td> </tr> </table></td> </tr> <tr> <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9"> <tr> <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> <td style="padding-left:15px;"><a href="index.php?l1=161&l2=171" class="tablink"><b>Career</b> | Apply now!</a></td> </tr> </table></td> </tr> <tr> <td ><table width="100%" border="0" cellpadding="3"> <tr> <td>Video</td> <td><select name="select" id=numpage onChange="change()"> <option value="0">VFM - ad</option> <option value="1">VFM - Introduction</option> <option value="2">VFM - VietNam: The potential market</option> </select> </td> </tr> </table> <param name="quality" value="high" /> <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> </tr> </table>
Thanks
Last edited by gits : February 29th, 2008 at 06:45 AM.
Reason: added code tags
|
|
February 29th, 2008 06:54 AM
# 4
|
Re: Javascript and flash
hi ...
first give your embed-node an id:
Code: ( text )
second chnage the change-function to this:
Code: ( text )
funtion change(node) { var video = document.getElementById('video_container'); video[i].src = "flash/video" + node.value + ".swf"; }
last - call the function like this:
Code: ( text )
<select name="select" id="numpage" onchange="change(this);">
kind regards
|
|
March 1st, 2008 05:32 PM
# 5
|
Re: Javascript and flash
am i correct with this?Thanks yo yr help
Code: ( text )
<style type="text/css"> <!-- .style20 {font-size: 9px} --> </style> <!-- <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> funtion change(node) { var video = document.getElementById('video_container'); video[i].src = "flash/video" + node.value + ".swf"; } //--> </SCRIPT> <table border="0" cellspacing="2"> <tr><br /><br /><br /><br /><br /><br /></tr> <tr> <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9"> <tr> <td><img src="img/latest news.jpg" alt="ee" width="41" height="34" /></td> <td style="padding-left:15px;"><p align="left"><span class="style20"><strong>Lastest News</strong> | Download here</span> </p></td> </tr> </table></td> </tr> <tr> <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9"> <tr> <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> <td style="padding-left:15px;"><a href="index.php?l1=161&l2=171" class="tablink"><b>Career</b> | Apply now!</a></td> </tr> </table></td> </tr> <tr> <td ><table width="100%" border="0" cellpadding="3"> <tr> <td>Video</td> <td><select name="select" id=numpage onChange="change(this)"> <option value="0">VFM - ad</option> <option value="1">VFM - Introduction</option> <option value="2">VFM - VietNam: The potential market</option> </select> </td> </tr> </table> <param name="quality" value="high" /> <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> </tr> </table>
|
|
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.
|
|
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
|
|
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
|
|
March 3rd, 2008 12:36 PM
# 9
|
Re: Javascript and flash
ahhhrg :) ... sorry ... my bad i gave you the following line:
Code: ( text )
video[i].src = "flash/video" + node.value + ".swf";
just use:
Code: ( text )
video.src = "flash/video" + node.value + ".swf";
kind regards
|
|
March 3rd, 2008 05:10 PM
# 10
|
Re: Javascript and flash
Still not working.Even I changed to this :
Code: ( text )
<style type="text/css"> .style20 {font-size: 9px} </style> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> function change(node) { var video = document.getElementById('video_container'); video.src = "flash/video" + node.value + ".swf"; } </SCRIPT> <table border="0" cellspacing="2"> <tr><br /><br /><br /><br /><br /><br /></tr> <tr> <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9"> <tr> <td><img src="img/latest news.jpg" alt="ee" width="41" height="34" /></td> <td style="padding-left:15px;"><p align="left"><span class="style20"><strong>Lastest News</strong> | Download here</span> </p></td> </tr> </table></td> </tr> <tr> <td style="padding-left:2px;"><table width="239" border="0" cellpadding="0" cellspacing="0" bgcolor="#d4d8d9"> <tr> <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> <td style="padding-left:15px;"><a href="index.php?l1=161&l2=171" class="tablink"><b>Career</b> | Apply now!</a></td> </tr> </table></td> </tr> <tr> <td ><table width="100%" border="0" cellpadding="3"> <tr> <td>Video</td> <td><select name="select" id="numpage" onchange="change(this);"> <option id="0" value="0">VFM - ad</option> <option id="1" value="1">VFM - Introduction</option> <option id="2" value="2">VFM - VietNam: The potential market</option> </select> </td> </tr> </table> <param name="quality" value="high" /> <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> </tr> </table>
|
|
March 5th, 2008 04:18 PM
# 11
|
Re: Javascript and flash
pls help!!!
have any solutions for this?
thanks alot
|
|
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 )
function change(node) { var video = document.getElementById('video_container'); var n_video = video.cloneNode(true); n_video.src = "flash/video" + node.value + ".swf"; video.parentNode.replaceChild(n_video, video); }
kind regards
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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 )
<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><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="flash/video0.swf" quality=high bgcolor=#FFFFFF WIDTH="204" HEIGHT="183" NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>
Second :
Code: ( text )
<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
|
|
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
|
|
March 28th, 2008 08:20 AM
# 21
|
Re: Javascript and flash
the function will be like this ,am i right?
Code: ( text )
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> function change(node) { var movie = document.getElementById('video_container'); var n_movie = movie.cloneNode(true); n_movie.value= "flash/video" + node.value + ".swf"; movie.parentNode.replaceChild(n_movie, movie); } </SCRIPT>
|
|
March 28th, 2008 04:01 PM
# 22
|
Re: Javascript and flash
nope ... that should have worked with the 'embed-version' ... :)
try this:
Code: ( text )
function change(node) { var video = document.getElementById('video_container'); var o_param = video.getElementsByTagName('param')[0]; var n_param = o_param.cloneNode(true); n_param.setAttribute('value', 'flash/video' + node.value + '.swf'); n_param.parentNode.replaceChild(n_param, o_param); }
kind regards
|
|
March 29th, 2008 06:17 PM
# 23
|
Re: Javascript and flash
i changed the code like this :
Code: ( text )
<!--<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> function change(node) { var video = document.getElementById('video_container'); var n_video = video.cloneNode(true); n_video.src = "flash/video" + node.value + ".swf"; video.parentNode.replaceChild(n_video, video); } </SCRIPT>--> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> function change(node) { var video = document.getElementById('video_container'); var o_param = video.getElementsByTagName('param')[0]; var n_param = o_param.cloneNode(true); n_param.setAttribute('value', 'flash/video' + node.value + '.swf'); o_param.parentNode.replaceChild(n_param, o_param); } </SCRIPT> <table> <tr> <td style="padding-left:0px;"><table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="img/latestnews.gif" width="204"></td> </tr> </table></td> </tr> <tr> <td style="padding-left:0x;"><table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="img/career-icon.gif" width="204" border="0"></td> </tr> </table></td> </tr> <table> <tr> <td align="right" bgcolor="#cacfd0"><table width="100%" border="0" cellpadding="3"> <tr> <td>Video</td> <td><select name="select" style="width:140px;" onchange="change(this);"> <option id="0" value="0">VFM - ad</option> <option id="1" value="1">VFM - Introduction</option> <option id="2" value="2">VFM - VietNam: The potential market</option> </select> </td> </tr> </table> <!--<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><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="flash/video0.swf" id="video_container" quality=high bgcolor=#FFFFFF WIDTH="204" HEIGHT="183" NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></tr></table> <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"><param name="quality" value="high" /> <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> --> <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> </tr></table>
but the video's disappeared in FF , and in IE ,video0 appear but can not change to the others
| |