Flash CS3 swf 加载到 Flex 中的问题(位图)
我已经加载了在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您到底什么时候调用 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!
我找到了解决这个问题的方法。问题是因为我犯了一个愚蠢的错误。
问题出在上面一行。 “someEvent”是由 FileReference.load() 生成的,我没有意识到数据是 ByteArray 而不是 Bitmap。
一直以来,我都将 byteArray 传递给一个仅接受位图的函数。
对不起各位,我的错!
谢谢你的时间。
磷
I found a solution to this. The problem was because of a silly error I made.
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