我需要將在AS2 swf中創建的BitmapData對象傳輸到AS3 swf。我正在使用gskinner的SWFBridge在兩部Flash動畫之間建立雙向通信。通過SWFBridge將ASmapf中的BitmapData對象傳輸到父AS3 swf
AS3電影加載完全獨立工作的AS2 swf,並允許用戶操縱影片剪輯並最終從他創建的作品中生成一個圖像。我需要AS3電影來接收這個圖像(bitmapData),做一些花哨的圖像處理的東西,AS2無法做到,併發送新的圖像回到AS2電影。
因此,這裏的代碼
AS2 SWF:
var userCompo_mc:MovieClip = container.createEmptyMovieClip("userCompo_mc",10);
var image:BitmapData = new BitmapData(userCompo_mc._width, userCompo_mc._height);
finalCompo.attachBitmap(image); // Just to make sure the final bitmap is right
image.draw(userCompo_mc, compo.title);
//Send the image to the AS3 movie
sb1.send("imageTransfer",image);
AS3 SWF:
function imageTransfer(bitmapData:BitmapData, title:String):void
{
var bmp:Bitmap = new Bitmap(bitmapData);
this.addChild(bmp);
trace(title); // --> returns the right title
trace(bitmapData); // --> returns null
}
我想使用類似copyPixel32(),保存一切到一個數組然後將它傳遞給AS3會做到這一點,但它確實是一個表演豬。
此外,我不是允許將AS2 swf轉換爲AS3代碼。
有什麼建議嗎?
謝謝你!
如何通過as2中的像素循環,使用uint填充單個數組並檢查是否可以發送這些數組。如果這樣,你可以將該陣列轉換爲向量。使用setVector(http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html?filter_coldfusion=9&filter_flex=3&filter_flashplayer=10&filter_air=1.5#setVector ()) –
2011-01-05 15:46:11
我認爲它可以工作,但使用getPixel32()在as2中循環像素大約需要3到4秒。我認爲這是太多時間,我需要更快的速度,因爲用戶需要儘快查看結果以執行其他任務。 – 2011-01-05 15:56:25