Flash
Action Script FlashBug
0最近搞了下 Flash 的 Action Script,水挺深的,完全外行。
遇到一个跨域的问题,域名 front.com 调用 static.net 上面的 flash.swf,由于权限问题导致 Flash 提供的方法不能被 Javascript 调用。
问了一个专门搞 Flash 的“专家”,看了下我调用的代码,抓耳挠腮搞了半天没搞明白,最后给了个结论:你不能引用 dev.cn 上面的 flash.swf,因为跨域,改成 static.net 域名的就好了。
邪了门了!我问:那不一样还是跨域么,dev.cn 跟 static.net 都是跨域,有区别吗?
那 2B 回答道:static.net 都有问题,dev.cn 就更有问题了!
我 TMD 晕死算了!心说怎么碰上你这么个 SB!不会就说不知道,还能少耽误我点时间。装了半天孙子,给出这么一个 SB 结论!
背景资料,我虽然不会开发 Flash,但也知道有 crossdomain.xml 这么个配置文件。我已经用 md5 验证过 dev.cn 和 static.net 都包含此文件且内容严格一致!
后来还是另一位自称“初学者”的兄弟帮我找到了问题,还教了我很多查问题的方法。
比如,在 Firefox 上装一个 FlashBug 插件,再下载一个 Flash Debug Player 10,安装完成后重启 Firefox,就可以输出 Flash 的 trace 信息。
在开发 Flash 的时候,在关键点用 try catch 和 trace 可以确定问题。
果不其然,通过日志发现 ExternalInterface 未定义,然后再看 fla 文件的属性,原来是 version 设置成 Flash Player 6 了,改成 8,再编译,问题立刻消失!
现在心情不错,不仅解决了问题,还学到了解决问题的方法,哈哈~~
flash wmode 参数详解 解决 flash 覆盖问题
0转自:http://www.neoy.cn/?p=158 多谢博主的文章,帮我解决了大问题~~
在做web开发中可能会遇到flash遮挡页面中元素的情况,无论怎么设置flash容器和层的深度(z-index)也无济于事,现有的解决方案是在插入flash的embed或object标签中加入”wmode”属性并设置为wmode=“transparent”或”opaque”,但wmode属性到底是什么意义,为什么可以解决这个问题呢?
window mode(wmode)
wmode即窗口模式总共有三种,看看当年Macromedia官方的说法:
- 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 模式
默认情况下的显示模式,在这种模式下flash player有自己的窗口句柄,这就意味着flash影片是存在于Windows中的一个显示实例,并且是在浏览器核心显示窗口之上的,所以flash只是貌似显示在浏览器中,但这也是flash最快最有效率的渲染模式。由于他是独立于浏览器的HTML渲染表面,这就导致默认显示方式下flash总是会遮住位置与他重合的所有DHTML层。
但是大多数苹果电脑浏览器会允许DHTML层显示在flash之上,但当flash影片播放时会出现比较诡异的现象,比如DHTML层像被flash刮掉一块一样显示异常。
Opaque 模式
这是一种无窗口模式,在这种情况下flash player没有自己的窗口句柄,这就需要浏览器需要告诉flash player在浏览器的渲染表面绘制的时间和位置。这时flash影片就不会在高于浏览器HTML渲染表面而是与其他元素一样在同一个页面上,因此你就可以使用z-index值来控制DHTML元素是遮盖flash或者被遮盖。
Transparent 模式
透明模式,在这种模式下flash player会将stage的背景色alpha值将为0并且只会绘制stage上真实可见的对象,同样你也可以使用z-index来控制flash影片的深度值,但是与Opaque模式不同的是这样做会降低flash影片的回放效果,而且在9.0.115之前的flash player版本设置wmode=”opaque”或”transparent”会导致全屏模式失效。
了解了各种模式的实现方式和意义在以后的开发中就可以按照具体情况选择设置wmode属性的值了。
