当Flash应用程序和页面的其他元素出现重叠时,就会有显示顺序上的问题。默认情况下,Flash应用程序都是优先于其它HTML页面元素而显示在最顶层。要解决这个问题,主要是利用FLASH对象的一个关键属性wmode(window mode)。wmode属性共有三个属性值:Window/Opaque/transparent,在官方文档中已有细致的说明:
* Window: Use the Window value to play a Flash Player movie in its own rectangular window on a web page. This is the default value for wmode and it works the way the classic Flash Player works. This normally provides the fastest animation performance.
* Opaque: By using the Opaque value you can use JavaScript to move or resize movies that don’t need a transparent background. Opaque mode makes the movie hide everything behind it on the page. Additionally, opaque mode moves elements behind Flash movies (for example, with dynamic HTML) to prevent them from showing through.
* Transparent: Transparent mode allows the background of the HTML page, or the DHTML layer underneath the Flash movie or layer, to show through all the transparent portions of the movie. This allows you to overlap the movie with other elements of the HTML page. Animation performance might be slower when you use this value.
“Window”窗口模式是默认值。在 Web 页上用影片自己的矩形窗口来播放应用程序,它表明 Flash 应用程序与 HTML 层没有任何交互,并且始终位于最顶层。
“Opaque”不透明模式。使Flash应用程序隐藏该页面上所有位于它之后的元素内容。
“Transparent”透明模式。使 HTML 页面的底层元素可以透过FLash应用程序的透明部分来进行显示,使用这个模式会降低动画的回放效果。
“Opaque ”和“Transparent ” 都可与 HTML 层交互,所以可以使用z-index属性来控制重叠元素的显示顺序。
wmode属性的用法:
针对IE:在<object></object>内加上参数 <param name="wmode" value="Opaque" />
针对非IE:在<embed />标签添加属性wmode="Opaque"