?
1、導入你想要使用的一個圖片到舞臺,設置屬性:寬、高與圖片相同。
2、把圖片拖到舞臺上,左對齊,上對齊。右鍵單擊圖片,轉換成電影修剪。(名字任意)圖1:

3、在屬性面板中輸入實例名字 " imageMC" 。圖2:

4、添加as層,輸入代碼:
//This?container?contains?all?the?mask?graphics
var?container:Sprite?=?new?Sprite();
addChild?(container);
//Set?the?container?to?be?the?image’s?mask
imageMC.mask?=?container;
//Set?the?starting?point
container.graphics.moveTo?(mouseX,?mouseY);
addEventListener?(Event.ENTER_FRAME,?enterFrameHandler);
/*Draw?a?new?rectangle?in?each?frame?and?add?it?onto?the?container
NOTE:?you?can?use?all?kinds?of?shapes,?not?just?rectangles!?*/
function?enterFrameHandler?(e:Event):void?{
????????container.graphics.beginFill(0xff00ff);
????????container.graphics.drawRect(mouseX-50,?mouseY-50,?100,?100);
????????container.graphics.endFill();
}
Mouse.hide();
5、完成,測試你的影片剪輯。遮罩可以做成任意形狀。只是矩形、圓形等簡單的圖形比較容易一些,復雜的圖形用代碼繪制要難一些。
附件下載:

遮罩實例(3).rar
?
本文轉自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/5291.html
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
