Flash SWF 在可见之前不会初始化 - 我可以强制它们初始化吗?

发布于 2024-08-31 00:06:16 字数 964 浏览 5 评论 0原文

我有一个应用程序需要在一系列行中渲染大约 100 个 flash 图形(以及其他 DOM 内容),这些行垂直延伸超出当前可见窗口很多次 - 换句话说,用户必须向下滚动才能看到所有不同的图表。

该应用程序也是动态的,当用户更改 DOM 中的值(页面上的任何位置)时,需要将该更改同时传播到所有 Flash 图形。

因此,我设置了所有的 externalInterface 回调,并小心地不让任何 JS 开始运行,直到非常重要的“flashIsReady”调用,并且......它工作得很好,直到我尝试使用新数据 update() 现有的 swf。

这是行为: - IE/Fox 中的所有 swf 加载(最初)= 良好。 - 使用新内容更新 swf 在 IE 中有效,但在 Fox 中无效 = 不好 - 在 Fox 中使用新内容更新 swf - 仅当 - 我向下滚动到页面底部,然后回到顶部 - 在此之前 - 我触发了 update()。

所以然后我开始追踪每次 swf 调用 JS 说“flash 已准备好”时,我意识到,Firfox 仅在 swf 变得可见时才渲染它们。说实话 - 这很好,实际上,我很确定 IE 也这样做。但问题是,Firefox 不仅不会初始化 swf,而且如果 swf 尚未可见,Firefox 甚至不会承认该 swf 存在(预计加载后)。

证据就是你会收到 JS 错误:

“[FlashDOMID].FlashMethod 不是函数”。

但是,向下滚动一点,等到其可见,然后跟踪突然开始亮起

“Flash Ready”、“Flash Ready”、“Flash Ready”,一旦它们全部准备好,一切就正常了。

有人告诉我 FF 在可见之前不会初始化 swf - 我可以强制它吗?如果您需要,我可以发布代码......但它相当重(很难从其余部分中剔除相关内容),如果可能的话,我想避免它(为了您的缘故)。

问题很简单 - 您是否遇到过这种情况?如果是,您找到解决方案了吗?现在有人如何强制初始化还不可见的 swf 吗?谢谢你们。

I have an application that needs to render about 100 flash graphs (as well as other DOM stuff) in a series of rows that vertically extend many times beyond the current visible window - in other words, the users have to scroll down see see all the different graphs.

This application is also dynamic and when a user changes a value in the DOM (anywhere on the page) it will need to propagate that change to all the Flash graphs at the same time.

So I setup all the externalInterface callbacks and was careful to not let any JS start going until the ever-so-important "flashIsReady" call and...it worked great until I tried to update() the existing swf's with new data.

Here was the behavior:
- All the swfs load (initially) in both IE/Fox = good.
- Updating swfs with new content works in IE but not in Fox = not good
- Updating swfs with new content works in Fox --ONLY IF-- I scrolled down to the bottom of the page, then back to the top -- BEFORE -- I triggered an update().

So then I started tracing out each time a swf called the JS to say "flash is ready" and I realized, Firfox only renders swfs as they become visible. And To be honest - that's fine and actually, I am pretty sure that IE does this too. But the problem is that not only does Firefox not initialize the swf, Firefox doesn't even acknowledge the swf exists (expect for after onload) if it has not yet been visible.

And the proof is that you get JS errors saying:

"[FlashDOMID].FlashMethod is not a function".

However, scroll down a little, wait until its visible and suddenly the trace starts lighting up

"Flash Ready", "Flash Ready", "Flash Ready" and once they are all ready, everything works fine.

Someone told me that FF does not init swf's until visible - can I force it? I can post code if you need...but its pretty heavy (hard to strip out the relevant from the rest) and I would like to avoid it (for your sakes) if possible.

The question is simple - have you had this happen and if so, did you find a solution? Does anyone now how to force a not-yet-visible swf to initialize? Thanks guys.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

匿名。 2024-09-07 00:06:16

所以......

经过大量的论坛搜索 - 我同意,没有优雅的方法来做到这一点哈哈!我最终寻求的解决方案基本上是为 $(document).ready() 上的每个 swf 制作 JS 对象

基本上,JS 对象将具有各种值,其中包括“data”和“isReady”。当 swf 变得可见并调用 JS 说“我准备好了”时,我会简单地捕获该调用,然后找到它所引用的 JS 对象(我设法通过将每个 swf 的 DOM id 作为其之一传递来做到这一点) flashVars;是的,这让我感觉很肮脏)。从那时起,它基本上只是一个游戏,以确保每个 JS 在我尝试操作它之前都已“isReady”。

在这整个混乱中唯一优雅的是,通过使用 JS 对象,我仍然可以通过简单地更新各自 JS 对象中的“数据”属性来将新数据应用到“隐藏”swf。然后,当 swf 最终变得可见时,我只需更新它拥有的任何数据(即当前数据)并且它运行得很好,但是,是的,我仍然同意整个情况是不幸的。

所以... *回答。

So...

After a lot of forum searching - I agree, there is no graceful way to do this haha! The solution I ended up going for was basically to make JS objects for each swf on $(document).ready()

Basically, the JS object would have various values, among them "data" and "isReady". When a swf became visible and would call the JS to say "im ready" I would simply catch that call, then find the JS object it was referring to (I managed to do this by passing the DOM id for each swf as one of its flashVars; yes it made me feel dirty). From there it was basically just a game to make sure that the each JS had "isReady" before I tried manipulating it.

The only bit of elegance in this whole mess was that by using JS objects, I could still apply new data to "hidden" swfs by simply updating the "data" property in their respective JS objects. Then, when a swf finally became visible, I would just update whatever data it had (ie, current data) and it worked pretty well but yeah, I still agree that this whole situation is unfortunate.

So... *answered.

那片花海 2024-09-07 00:06:16

我知道这可能是一个迟到的答案。

但是你需要将你的wmode从不透明更改为wmode =“window”,这就是为什么它在firefox中无法正常工作,IE也做了同样的事情,但仅在第一页加载时。

将 wmode 设置为 opaque 会导致 Firefox 在浏览器查看之前不会初始化 swf。然而,这对于所有浏览器来说并不相同。 IE 仅在首页视图上执行此操作,chrome 和 safari 根本不执行此操作。

对我来说不幸的是,我发现这个问题寻找相反的答案。我试图让播放器在所有浏览器中不初始化,直到它在浏览器中可见。

I know this is probably a late answer.

But you need to change your wmode from opaque to wmode="window", that's why it's not working properly in firefox, IE doe the same thing, but only on the first page load.

Setting wmode to opaque causes firefox to not initialize the swf until it is viewed by the browser. However, this is not the same for all browers. IE only dose it on first page view, chrome and safari doesn't do it at all.

Unfortunately for me I found this question looking for the opposite. I'm attempting to make a player not initialize across ALL browsers until it is visible inside the browser.

忆伤 2024-09-07 00:06:16

我从来没有真正找到强制加载闪存的好方法,除了在页面初始化后重新定位元素,强制加载开始然后再次隐藏它们(便宜且令人讨厌,但似乎有效)。

将所有 Flash 元素定位在页面的左上角(以确保它们在页面加载时可见),然后使用 javascript 中的 pageLoad 函数根据需要重新定位页面下方的元素。 Jquery 可以让您使用 addClass() 和 removeClass() 函数非常轻松地完成这一切

i never really found a good way of forcing the load of the flash other than to reposition the elements after page init, forcing the load to start then hiding them again (cheap and nasty, but seems to work).

position all the flash elements towards the top left corner of the page (to make sure they are visible on page load) then use the pageLoad function in javascript to reposition the elements lower down the page as required. Jquery lets you do this all really quite easily with the addClass() and removeClass() functions

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文