简体   繁体   English

在div中隐藏/显示swf?

[英]Hiding/Showing a swf in a div?

I have a flex app that I want to hide in a div until the user clicks a link or element of some type. 我有一个Flex应用程序,我想隐藏在div中,直到用户单击某种类型的链接或元素。 I've noticed that embedding the swf in a div with style display:none does not actually hide the swf, so how would I go about accomplishing this? 我注意到将swf嵌入到具有display:none样式的div中实际上并没有隐藏该swf,那么我将如何实现这一目标?

The goal is to have the flex app loading in the background while the user does other things. 目标是在用户执行其他操作时在后台加载flex应用。 Thanks. 谢谢。

Try setting the following wmode to your flash object, and use visibility: hidden; 尝试将以下wmode设置为Flash对象,并使用visibility: hidden; as well. 也一样

<param name="wmode" value="opaque" />
<embed ... wmode="opaque" ... />

By default, flash basically overlays a window over your content, which is: 默认情况下,Flash基本上会在您的内容上覆盖一个窗口,即:

  1. Has a greater z-index than anything on your page z索引比您页面上的任何东西都要大
  2. Doesn't inherit display from its parent (setting display: none; visibility: hidden; to the <object> tag will work). 不继承其父项的display: none; visibility: hidden; (设置display: none; visibility: hidden;<object>标签起作用)。

By setting wmode to opaque , it basically tells flash to treat your <object> as a normal DOM tag, which responds to normal inheritance and z-index rules. 通过将wmode设置为opaque ,它基本上告诉Flash将<object>视为普通的DOM标签,该标签响应普通的继承和z-index规则。 It has a very small performance cost. 它具有非常小的性能成本。

Also, note that some browsers will not load the object until it is displayed. 另外,请注意,某些浏览器在显示对象之前不会加载该对象。

I usually just force the height/width of the container to 1 by 1 px... 我通常只是将容器的高度/宽度强制为1 x 1像素...

<div style="height:1px; width:1px;" >... flash goes here ...<div>

Then, when I need the flash, I will re-set the height/width as appropriate. 然后,当我需要闪光灯时,我将适当地重新设置高度/宽度。 Note, you may want to put this into a parent container if you want to just reset the hw to "100%" which will bind to a parent div, with a "position:relative; height:?px; width:?px" setting. 请注意,如果您只想将硬件重置为“ 100%”,它将绑定到父div,则可能要将其放置到父容器中,并带有“ position:relative; height:?px; width:?px”设置。

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

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