AS3.0遮罩动画实例

悲酥清风 Flash评论4,267,904阅读模式

这是一个非常容易的实例教程。将学习如何创建一个图像擦子,是遮罩的另一种效果。

演示:

1、导入你想要使用的一个图片到舞台,设置属性:宽、高与图片相同。

2、把图片拖到舞台上,左对齐,上对齐。右键单击图片,转换成电影修剪。(名字任意).

3、在属性面板中输入实例名字 " imageMC" 。

4、添加as层,输入代码:

  1. //This container contains all the mask graphics
  2. var container:Sprite = new Sprite();
  3. addChild (container);
  4. //Set the container to be the image's mask
  5. imageMC.mask = container;
  6. //Set the starting point
  7. container.graphics.moveTo (mouseX, mouseY);
  8. addEventListener (Event.ENTER_FRAME, enterFrameHandler);
  9. /*Draw a new rectangle in each frame and add it onto the container
  10. NOTE: you can use all kinds of shapes, not just rectangles! */
  11. function enterFrameHandler (e:Event):void {
  12.         container.graphics.beginFill(0xff00ff);
  13.         container.graphics.drawRect(mouseX-50, mouseY-50100100);
  14.         container.graphics.endFill();
  15. }
  16. Mouse.hide();

Flash最后更新:2015-6-7
悲酥清风
  • 本文由 发表于 2014年12月17日 22:41:43

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定