简体   繁体   中英

Load swf before it is shown

basically, I have an swf file that is set to play 10 seconds after a button is pressed. When the swf is suposed to pop up, it shows a white screen while the swf is loading. I would like to elimenate that. This is my javascript that I am using right now to show the swf 10 seconds after the button push:

<script type="text/javascript">
    function flash() {
 $('#stage').html('<OBJECT style="z-index:2; position:absolute; top:20%; left:15%;" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="90%" HEIGHT="70%" id="rice" ALIGN=""><PARAM NAME=movie VALUE="rice.swf"><PARAM NAME=quality VALUE=low><EMBED src="rice.swf" quality=low bgcolor=#EEEEEE WIDTH="90%" HEIGHT="90%" NAME="rice" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>');
}
</script>

I am using setTimout for the wait time. That works, but as I said, it shows the white (well, I changed the bgcolor to EEEEEE so that color) "loading" screen. I tried putting "display:none" in the div, the object tag, and the embed tag where the swf is, and then using a javascript function to change the "display:none" to "display:block" when the button is pressed. I know for a fact that that JS function works, because I am using it for other elements on the page. Here is that JS:

<script type="text/javascript">
    function showStuff(id) {
        document.getElementById(id).style.display = 'block';
}
</script>

And if I were to do that (hide then show the swf) I would need to stop the sound of it. I wouldnt need to pause the swf while it is hidden because it is a short .5 second looping animation. I hope someone can help, thanks.

You should use the jquery library to access the show() and hide() functions :) like so...

function showStuff(id) {
     $('#' + id).show();
}

also... to hide it when the document is ready do...

$(document).ready(function(){ 
    $('#YourId').hide(); 
}); 

as for stopping the sound, you should go here: Stop music from in flash from javascript event

Hope this helped :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM