Derleek Posted July 29, 2008 Share Posted July 29, 2008 So javascript is some-what uncharted ground for me, but i think i have some use for it here. I have a flash video embeded over the content of a website, i need it to disappear once it is done running. Is there a way to do that using JavaScript? - its the only possible solution that is coming to mind. I am thinking that i have a script that writes the div/embed for 5 seconds (duration of the .swf) and stops after that... Is this possible? are there any other (possible/better) solutions to this? Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 29, 2008 Share Posted July 29, 2008 I don't know jack about Flash. But, you can certainly do what you describe. I'm just not certain that a flash object will initiate correctly. I'll let you figure that out. Here is some rough code: <html> <head> <script type="text/javascript"> function showFlash(objID, source, width, height, seconds) { milliseconds = seconds * 1000; //Convert to milliseconds var embedCode = '<embed type="application/x-shockwave-flash"'; embedCode += ' pluginspage="http://www.adobe.com/go/getflashplayer"'; embedCode += ' width="'+width+'" height="'+height+'" src="'+source+'" />'; embedCode += '<noembed><p>Alternative content</p></noembed>'; document.getElementById(objID).style.display = 'inline'; document.getElementById(objID).innerHTML = embedCode; window.setTimeout("hideFlash('"+objID+"')", milliseconds); } function hideFlash(objID) { document.getElementById(objID).style.display = 'none'; } window.onload = function xxx() { showFlash('flashDiv', 'path/flash_movie.swf', 300, 150, 5); } </script> </head> <body> <div id="flashDiv" style="display:none;"></div> </body> </html> Quote Link to comment Share on other sites More sharing options...
secoxxx Posted July 29, 2008 Share Posted July 29, 2008 you can pass js variables from flash, for instance on the first frame when the movie starts loading you can in frame 1 in the flash file, getURL('showFlash()'); and the last frame getURL('hideFlash()'); and remove the timer and window.onload = function xxx() { showFlash('flashDiv', 'path/flash_movie.swf', 300, 150, 5); } and rework the embed code a lil from mjdamato's code Quote Link to comment Share on other sites More sharing options...
Derleek Posted July 30, 2008 Author Share Posted July 30, 2008 awesome! I don't have time to try this now, so i'm not going to click topic-solved JUUUUST yet because i want to make sure i can get it working first. but that looks awesome! now, what is all this +variable+ business? what exactly does that syntax do? Quote Link to comment Share on other sites More sharing options...
Derleek Posted July 30, 2008 Author Share Posted July 30, 2008 Ok, so i'm not really sure what is going on here... I put this code into the header of my php file... function showFlash(objID, source, width, height) { var embedCode = '<param name="'loop'"value="'false'"/><param name="'wmode'" value="'transparent'" />'; embedCode += '<embed type="application/x-shockwave-flash"'; embedCode += ' pluginspage="http://www.adobe.com/go/getflashplayer"'; embedCode += ' width="'+width+'" height="'+height+'" src="'+source+'" />'; document.getElementById(objID).style.display = 'inline'; document.getElementById(objID).innerHTML = embedCode; } function hideFlash(objID) {document.getElementById(objID).style.display = 'none';} window.onload = function xxx() { showFlash('flashDiv', 'fringe animation.swf', 1024, 450); } and I tried just putting getURL('hideFlash()'); in to the last frame in actionscript (although i'm not confident i did that correctly. so i did some research on Flash/JS communication (http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/) and came up with the code: import flash.external.*; function blah() { ExternalInterface.call("hideFlash","flashDiv"); } and injected it into the last frame of ActionScript. not quite sure why its not working. i'm guessing it MIGHT be how i put it into actionscript... Quote Link to comment Share on other sites More sharing options...
secoxxx Posted July 30, 2008 Share Posted July 30, 2008 it may be how the js is set up. when i get back ill through together a script that i know works as i have used it before. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.