Flash AS3 中的透明 jpeg 图像

发布于 2024-08-17 02:40:23 字数 433 浏览 5 评论 0原文

您好,有人可以提供帮助吗?我的闪光灯舞台上有两个图像(相机图像和风景图像),其想法是相机位于风景前面。问题是,虽然两张图像都在我的舞台上,但相机是完全透明的,看起来不对。如何设置大炮图像透明度,使其成为背景图像之上的实心图像。预先感谢您的任何提示!,米克

    // add images 

var cannon = new mc_cannon ;
var backGround = new mc_scene ;        


backGround.x = 200 ;
backGround.y = 200 ; 
addChild (backGround) ; 

setChildIndex(cannon,numChildren - 1);
cannon.alpha = 1 ;
cannon.x = 200 ;
cannon.y = 200 ; 
addChild (cannon) ;

Hi can anyone offer some help please ? I have two images on my flash stage (A camera image and a scenery image) The idea is that the camera is in front of the scenery. The problem is although both images are on my stage the camera is completely transparent and looks wrong . How can I set the cannon image transparency so that it is a solid image on top of the background image . Thanks in advance for any tips !, Mick

    // add images 

var cannon = new mc_cannon ;
var backGround = new mc_scene ;        


backGround.x = 200 ;
backGround.y = 200 ; 
addChild (backGround) ; 

setChildIndex(cannon,numChildren - 1);
cannon.alpha = 1 ;
cannon.x = 200 ;
cannon.y = 200 ; 
addChild (cannon) ;

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

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

发布评论

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

评论(1

骄傲 2024-08-24 02:40:23

只需查看您的代码,我猜测您的代码会导致运行时错误,因为您尝试将 setChildIndex() 方法与尚未添加到舞台(大炮)的显示对象一起使用。我不记得曾经不小心这样做过,所以我不确定是否确实引发了错误,但这样做与其他显示列表相关的程序员错误是一致的。

因为您首先添加背景,然后添加大炮,所以您根本不必使用 setChildIndex() 。大炮将被添加到背景之上。

此外,您谈到透明 JPEG 图像,但几乎从未使用过这种图像(虽然它确实存在于 JPEG 规范的补充中)。对于具有透明度的位图,您应该使用 PNG 图像。然后,在Flash CS4中,将导入图像的压缩设置为“照片(JPEG)”,Flash将其编码为JPEG,但保持透明度不变。

如果删除 setChildIndex() 没有帮助,并且您确实能够在图像中导入 Alpha 通道,我发现很难想象问题可能是什么。您能否提供相机“完全透明”和“看起来完全错误”的屏幕截图?

干杯

Just looking at your code, I would guess that your code causes a runtime error, as you are trying to use the setChildIndex() method with a display object that has yet to be added to the stage (cannon). I can't remember ever accidentally doing this, so I'm not sure that an error is indeed thrown, but doing so would be consistent with other display-list related programmer errors.

Because you are adding the background first, and then the cannon, you shouldn't have to use setChildIndex() at all. The cannon will be added on top of the background.

Furthermore, you speak of transparent JPEG images, something that (while it does exist in an addition to the JPEG spec) is almost never used. You should use PNG images for bitmaps that have transparency. Then, in Flash CS4, set the compression of the imported image to "Photo (JPEG)", and it will be encoded by Flash as a JPEG, but keeping the transparency intact.

If removing setChildIndex() doesn't help, and you are indeed able to import the alpha channel in your images, I'm finding it really hard to imagine what the problem might be. Could you maybe supply a screen shot of the camera being "completely transparent" and "looking all wrong"?

Cheers

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