2013-02-17 167 views
0

我試圖揭示這個影片剪輯圖像這原本是一個位圖,但需要用作此目的的位圖衝突。由於某種原因,它不工作... 它不扔任何錯誤......我需要這個圖像被屏蔽就可以了用戶按下......後來與另一個位圖來進行功能進行比較。但由於某種原因,正如我之前提到的那樣,它不能解決問題。有人能幫幫我嗎??這是它的代碼...影片剪輯與圖蒙

import flash.display.Graphics; 
import flash.display.MovieClip; 
import flash.display.BitmapData; 

var mouseclick:Number=0; 
var maskedbg_mc:maskedbg = new maskedbg(); 
var masking:Sprite = new Sprite()    

addChild (maskedbg_mc); 
maskedbg_mc.x = 18; 
maskedbg_mc.y = 343; 
var bitmapDataCopy:BitmapData = new BitmapData(742,165,true,0x00FFFFFF); 
var b:Bitmap = new Bitmap(bitmapDataCopy); 

bitmapDataCopy.draw(maskedbg_mc); 

b.mask = masking; 
var Testing:BitmapData = new BitmapData(maskedbg_mc.width, maskedbg_mc.height, true, 0x00000000); 


addChild(masking); 


stage.addEventListener(MouseEvent.MOUSE_DOWN, Pressing); 
stage.addEventListener(MouseEvent.MOUSE_MOVE, Moving); 
stage.addEventListener(MouseEvent.MOUSE_UP, Lifting); 


function Pressing(event:MouseEvent):void { 
mouseclick = 1; 
} 


function Moving(event:MouseEvent):void { 
if (mouseclick == 1) { 
masking.graphics.beginFill(0x000000); 
masking.graphics.drawEllipse(mouseX, mouseY, 70, 60); 
masking.graphics.endFill(); 
} 
} 


function Lifting(event:MouseEvent):void { 
mouseclick = 0; 
} 

if (bitmapDataCopy.compare(Testing) ==0) 
{ 
    trace ("Awesomness") 
} 

回答

1

俯瞰你的代碼,我注意到您不添加「B」(蒙面的DisplayObject)顯示列表,而要添加「maskedbg​​_mc」這實際上ISN」 t在您的代碼中被屏蔽。你有這個2顯示對象的理由嗎?

我會建議你將以下ActionScript編碼約定:

http://sourceforge.net/adobe/flexsdk/wiki/Coding%20Conventions/

你的代碼看起來相當混亂,當你有兩個變量和函數以大寫首字母,它們看起來像類。