检查的透明度 [英] Check transparency

查看:107
本文介绍了检查的透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的swf文件(900x600),而该文件的主要部分是transparense。 所以,我想通过单击SWF文件知道无论用户点击图像transa preNT的一部分或不...

I have swf file(900x600) and main part of that file is transparense. So I want by clicking in swf file know either user clicks on transaprent part of image or not...

我可以通过

event.localX
event.localY

那么如何知道被点击的部分SWF是透明与否?

So how to know in clicked part swf is transparent or not?

推荐答案

首先,可以肯定的,那你有一些透明的精灵在你的SWF的背景 - 否则你将不会收到事件。

First of all, be sure, that you have some transparent sprite on background of your swf - otherwise you won't receive event.

二,不要用纯粹的本地坐标,它们可以包含另一个内部对象的本地坐标,而你根本需要他们。例如,我曾经使用过舞台的坐标

Second, do not use pure local coordinates, they can contain local coordinates of another inner object, while you need them from root. For example, I've used stage's coordinates

如果您收到鼠标事件,添加鼠标事件监听到SWF的根和写入以下内容:

If you receive mouse event, add mouse event listener to the root of that swf and write following:

        var bmd:BitmapData = new BitmapData(1, 1, true, 0);
        var pt:Point = new Point();
        var m:Matrix = new Matrix();

        m.translate(-e.stageX, -e.stageY);
        bmd.draw(this, m);
        var transparent:Boolean = !bmd.hitTest(pt, 0x00, pt);

        trace('color: '+bmd.getPixel32(0,0).toString(16));
        trace('is tranparent? ' + transparent);

        bmd.dispose();

这篇关于检查的透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆