Flash CS3 swf 加载到 Flex 中的问题(位图)

发布于 2024-08-03 04:34:54 字数 618 浏览 2 评论 0原文

我已经加载了在 Flash CS9 (AS3) 中创建的 SWF。我在将位图(或 BitmapData)从 Flex 应用程序传递到加载的 SWF 时遇到问题。

在从 Flex 加载的文件中调用其他函数是可行的,但是当我尝试将位图传递给加载的 SWF 时,没有任何反应。下面是示例代码:

FLEX:

try{
    var bm:Bitmap = (someEvent.data as Bitmap);
    imageHolder.source = bm; // works fine with container inside flex app
    flashSWF.setPhotoBitmap(bm); 
}catch(e:Error){
    tracer("error = "+e);   
}

FLASH:

function setPhotoBitmap(b:Bitmap):void{
    addChild(b); // throws error
}

上面抛出 TypeError: Error #2007 可能是因为 b 为空。

我是否应该注意任何限制,或者我在这里做错了什么?

干杯!

I have loaded a SWF which is created in Flash CS9 (AS3). I'm having problem passing Bitmap (or BitmapData) from the flex app to the loaded SWF.

Invoking of other functions in the loaded from Flex works, but when I try to pass a Bitmap to the loaded SWF, nothing happens. Here's a sample code:

FLEX:

try{
    var bm:Bitmap = (someEvent.data as Bitmap);
    imageHolder.source = bm; // works fine with container inside flex app
    flashSWF.setPhotoBitmap(bm); 
}catch(e:Error){
    tracer("error = "+e);   
}

FLASH:

function setPhotoBitmap(b:Bitmap):void{
    addChild(b); // throws error
}

The above throws a TypeError: Error #2007
Probably because b is null.

Is there any restriction I should be aware of, or am I doing something wrong here?

Cheers!

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

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

发布评论

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

评论(2

羁拥 2024-08-10 04:34:54

您到底什么时候调用 setPhotoBitmap ?

我认为如果您在

祝你好运!

When exactly are you calling setPhotoBitmap ?

I think you should be fine if you do it in the INIT handler of your SWFLoader instance. That is when your swf is loaded and all of it's classes initialized.

Goodluck!

自控 2024-08-10 04:34:54

我找到了解决这个问题的方法。问题是因为我犯了一个愚蠢的错误。

var bm:Bitmap = (someEvent.data as Bitmap);

问题出在上面一行。 “someEvent”是由 FileReference.load() 生成的,我没有意识到数据是 ByteArray 而不是 Bitmap。

一直以来,我都将 byteArray 传递给一个仅接受位图的函数。

对不起各位,我的错!

谢谢你的时间。

I found a solution to this. The problem was because of a silly error I made.

var bm:Bitmap = (someEvent.data as Bitmap);

The problem was in the above line. 'someEvent' was generated by FileReference.load() and I did not realize that data is ByteArray and not a Bitmap.

All this time, I was passing byteArray to a function which accepts only bitmap.

Sorry folks, my bad!

Thanks for you time.

P

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