Flex:如何展平加载的 swf 然后应用 alpha,而不是应用 alpha 然后展平

发布于 2024-11-01 00:28:33 字数 536 浏览 3 评论 0原文

我有一个 Flex 应用程序,并试图在谷歌地图上显示一些动画矢量形状。为此,我加载一个外部 SWF(内容是动态的,因此我必须在运行时加载,据我所知,SWF 是唯一支持动画的可加载格式)并使用叠加层将其放置在地图上。

然后我需要控制 SWF 的 Alpha。设置它很简单,但由于某种原因,Alpha 似乎应用于 SWF 内的子形状,只有在此之后图像才会合成到地图上。这使得绿色斑点顶部的黄色斑点看起来是黄绿色,而不仅仅是黄色。

我需要以某种方式告诉flex/flash“渲染/展平SWF,然后应用alpha”,而不是“将alpha应用到各个子形状,然后展平到地图”。理想情况下,无需通过 BitmapData 对象或类似对象。

包含层次结构是Map -> Blob 管理器 ->装载机-> Loader.content(SWF),我尝试分别将 alpha 应用于 BlobManager、Loader 和 Loader.content,但没有区别。我尝试过在较低层上使用cacheAsBitmap,然后应用较高层的alpha,但无济于事。

对于下一步尝试什么有什么建议吗?谢谢!

I have a flex application and am trying to show some animated vector shapes on a google map. To do this I load an external SWF (the content is dynamic, so I have to load at runtime and SWF was the only loadable format supporting animation AFAIK) and place it on the map using an overlay.

I then need to control the alpha of the SWF. Setting it is straightforward, but for some reason the alpha appears to be applied to the sub-shapes inside the SWF, and only after that is the image composited onto the map. This makes the yellow blob that is on top of the green blob appear yellow-green rather than just yellow.

I need to somehow tell flex/flash to "render/flatten the SWF, then apply the alpha", rather than "apply the alpha to the individual sub-shapes, then flatten to the map". Ideally without going via e.g. a BitmapData object or similar.

The containment hierarchy is Map -> BlobManager -> Loader -> Loader.content (the SWF) and I've tried applying the alpha to the BlobManager, Loader, and Loader.content separately, but no difference. I've tried cacheAsBitmap on the lower layers and then applying alpha higher up to no avail.

Any suggestions for what to try next? Thanks!

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

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

发布评论

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

评论(2

ぃ弥猫深巷。 2024-11-08 00:28:33

尝试 BlendMode.LAYER,它拯救了许多人的生命。

Try BlendMode.LAYER, it saved many lives.

太阳男子 2024-11-08 00:28:33

我认为如果不在位图上绘制加载的内容并使用它来显示 Alpha,您就无法做到这一点。
不过,这很容易,但如果加载的内容来自另一个域并且不允许您从中创建 bitmapData,您可能会遇到安全违规。

// content is the loaded external swf, or the Loader itself?
var bitmapData:BitmapData = new BitmapData(content.width, content.height);
bitmapData.draw(content);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.alpha = .5;
addChild(bitmap);

甚至可能不需要显示加载的内容(尽管我还没有尝试过),您也可以使用矩阵仅将其中的一部分用作位图数据。

编辑:对于动画,另一种选择是加载动画 gif,如下所述: http://www.bytearray .org/?p=95(我没有这方面的经验,所以我不能说它是否真的适合你),或者使用视频。

I don't think you can do that without drawing the loaded content on a Bitmap and using that to display with alpha.
It is quite easy though, although you might run into security violations if the loaded content is from another domain and won't let you create bitmapData from it.

// content is the loaded external swf, or the Loader itself?
var bitmapData:BitmapData = new BitmapData(content.width, content.height);
bitmapData.draw(content);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.alpha = .5;
addChild(bitmap);

It may not even be necessary to display the loaded content (although I haven't tried that) and you can also take only part of it to use as bitmapData using a Matrix.

EDIT: for animation, another option is to load an animated gif as described here: http://www.bytearray.org/?p=95 (I have no experience with it so I can't say if it'd really work for you), or use video.

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