as3制作酷炫运动遮罩效果(三)

 
1、导入你想要使用的一个图片到舞台,设置属性:宽、高与图片相同。
2、把图片拖到舞台上,左对齐,上对齐。右键单击图片,转换成电影修剪。(名字任意)图1:
[img]/uploads/allimg/100126/2341180.png[/img]
3、在属性面板中输入实例名字 " imageMC" 。图2:
[img]/uploads/allimg/100126/2341181.png[/img]
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、完成,测试你的影片剪辑。遮罩可以做成任意形状。只是矩形、圆形等简单的图形比较容易一些,复杂的图形用代码绘制要难一些。
附件下载:
[img]/uploads/allimg/100126/2341182.gif[/img]
[url=http://www2.flash8.net/UploadTeach/201001/2010012620206372.rar]遮罩实例(3).rar[/url]

 
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/5291.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值