从Embedded类获取BitmapData

发布于 2024-11-04 20:22:17 字数 870 浏览 3 评论 0原文

[ Embed('Assests/ui/Main.swf', symbol='backgroundImage')]
    private var background01:Class;

    private function getBitmapData(className:String):BitmapData
            {
                var mc:MovieClip = (new background01) as MovieClip; 
                if (mc == null) throw new Error('mc is null');
                var myBitmapData:BitmapData = new BitmapData(mc.width , mc.height);
                myBitmapData.draw(mc)

                return myBitmapData;
            }

你好呀。我在解决这个问题时遇到了问题。我想从嵌入 Flash swf 文件中的符号返回 bitmapData。 background01是导出到Flash swf文件中as3的类名。正如你从上面看到的,我发现 swf 没有问题。我从 swf 文件中提取数据,没有任何问题。我可以输入 addChild(new background01) ,图像就会显示出来。但是当我尝试转换为 bitmap 、 bitmapasset 和 movieclip 时。它总是返回 null。我想访问此图像/电影剪辑的位图数据。它应该返回一个在 Flash 中绘制的顶点圆并创建为影片剪辑符号。所以我期望返回的是一个 MovieClip。

有没有人做过这个,如果是的话,你能提供一些示例代码吗? 谢谢林

X

[ Embed('Assests/ui/Main.swf', symbol='backgroundImage')]
    private var background01:Class;

    private function getBitmapData(className:String):BitmapData
            {
                var mc:MovieClip = (new background01) as MovieClip; 
                if (mc == null) throw new Error('mc is null');
                var myBitmapData:BitmapData = new BitmapData(mc.width , mc.height);
                myBitmapData.draw(mc)

                return myBitmapData;
            }

Hi there. I'm having a problem working this out. I want to return bitmapData from a symbol that is embedded in a flash swf file. background01 is the class name exported to as3 in the flash swf file. As you can see from above I'm finding the swf with no problem. and I'm pullin the data back from the swf file with no prob. I can type addChild(new background01) and the image will show up. But when I've tried to cast to a bitmap , bitmapasset and movieclip. It always returns null. I want to get access to the bitmapdata of this image/movieclip. It should be returning a vertex circle drawn in flash and created to be a movieclip symbol. So what I would expect to be returned would be a MovieClip.

Has anyone ever done this, and if so, could you provided some sample code..
Thanks

LinX

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

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

发布评论

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

评论(1

秋凉 2024-11-11 20:22:17

尝试:

var mc:MovieClip = (new background01()) as MovieClip; 

代替

var mc:MovieClip = (new background01) as MovieClip; 

Try:

var mc:MovieClip = (new background01()) as MovieClip; 

instead of

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