简体   繁体   English

在显示之前加载swf

[英]Load swf before it is shown

basically, I have an swf file that is set to play 10 seconds after a button is pressed. 基本上,我有一个swf文件,该文件设置为在按下按钮10秒后播放。 When the swf is suposed to pop up, it shows a white screen while the swf is loading. 如果要弹出swf,则在swf加载时会显示白屏。 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: 这是我现在正在使用的JavaScript,以在按下按钮10秒后显示swf:

<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. 我正在使用setTimout作为等待时间。 That works, but as I said, it shows the white (well, I changed the bgcolor to EEEEEE so that color) "loading" screen. 那行得通,但是正如我说的,它显示了白色(很好,我将bgcolor更改为EEEEEE从而使颜色)“正在加载”屏幕。 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. 我尝试将“ display:none”放在div,对象标签和swf所在的embed标签中,然后在按下按钮时使用JavaScript函数将“ display:none”更改为“ display:block” 。 I know for a fact that that JS function works, because I am using it for other elements on the page. 我知道JS函数有效,因为我将它用于页面上的其他元素。 Here is that JS: 这是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. 如果我要这样做(隐藏然后显示swf),则需要停止它的声音。 I wouldnt need to pause the swf while it is hidden because it is a short .5 second looping animation. 隐藏SWF时,我不需要暂停它,因为它是一个很短的.5秒循环动画。 I hope someone can help, thanks. 希望有人能帮助您,谢谢。

You should use the jquery library to access the show() and hide() functions :) like so... 您应该像这样使用jquery库访问show()和hide()函数:)。

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 至于停止声音,您应该去这里: 从javascript事件中停止播放Flash中的音乐

Hope this helped :) 希望这有帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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