检测损坏的闪存文件
我曾经不小心只将部分 Flash 程序上传到我的网站(即,它被截断),令我最惊讶的是,Flash 对象成功加载到网页中,没有出现任何错误,也没有发出任何警告。 (这是播放器的发布版本,调试版本的行为可能有所不同,我不知道。)当然,它无法正常工作,但是预加载器屏幕仍然正确显示,并且出现了下载和初始化才能正常完成。
我的问题是:有没有办法检测(在actionscript/flash或嵌入网页中)何时加载了这样一个损坏的flash对象? 当发生这种情况时,我可以使用预加载器发出警告吗?
I once accidentally uploaded only part of my flash program to my website (i.e., it was truncated), and to my biggest surprise, the flash object was loaded successfully into the webpage, no errors were raised, no warnings were given at all. (This was a release version of the player, the debug version might have behaved differently, I don't know.) Of course, it did not work properly, but still, the preloader screen was displayed correctly, and the download and initialization appeared to be finished normally.
My question is: is there a way to detect (either in actionscript/flash or in the embedding web page) when such a corrupted flash object has been loaded? Can I perhaps use the preloader to give a warning when this happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有很多方法可以从 SWF 文件中提取标头信息(包括其文件大小)。 由于此信息是在发布时写入的,因此如果文件在上传后被截断,它不会改变。 例如,您可以提取该信息并检查文件大小(根据 SWF 标头)是否 == 加载的字节数。
There are a lot of ways to extract the header info from a SWF file (including its file size). Since this info is written at publishing time, it won't change if the file is truncated after uploading it. So, for instance, you can extract that info and check if the file size (according to the SWF header) == bytes loaded.
我不知道任何特定于闪存的方法,但编写一个脚本来比较原始文件的 md5 哈希值与在线版本肯定不会困难。 甚至可以很容易地进行设置,使其在文件更改时自动运行。
I don't know of any flash-specific ways, but it certainly wouldn't be difficult to write a script that compares the md5 hash of the original file with the version you have online. It would even be easy to set up in such a way that it automatically ran whenever the file was changed.