阅读文章

Flash AS制作鼠标触发图片缓冲放缩

[日期:2007-11-01] 来源:  作者: [字体: ]

     本文中我们用Flash制作一个鼠标触发的动态实例:按下鼠标拖动图片,图片会缓冲放大并移到最前面,松开鼠标停止拖动图片缓冲缩小。

  效果如下。

/imagelist/2007/296/r3c90i0wmoz6.swf
用鼠标点击图片并拖动,您将看到图片缓冲放缩效果

  Flash中制作步骤:

  先在Flash中导入几张图片,分别转为影片元件,拖到主场景,实例名分别为pic0_mc、pic1_mc、pic2_mc……

  在帧上写如下代码:

for (var d:Number = 0; d<=2; d++) {
this["pic"+d+"_mc"].onPress = function() {
  mx.behaviors.DepthControl.bringToFront(this);//移到最前
  startDrag(this);
  this.onEnterFrame = function() {
   this._xscale += (200-this._xscale)/4;//缓冲放大
   this._yscale += (200-this._yscale)/4;
   if (this._xscale>=200) {
    delete this.onEnterFrame;
   }
  };
};
this["pic"+d+"_mc"].onRelease = function() {
  stopDrag();
  this.onEnterFrame = function() {
   this._xscale -= (this._xscale-100)/4;//缓冲缩小
   this._yscale -= (this._yscale-100)/4;
   if (this._xscale<=100) {
    delete this.onEnterFrame;
   }
  };
};
}


阅读:
录入:blue1000

评论 】 【 推荐 】 【 打印
上一篇:关于Flash中注册点与中心点的区别
下一篇:Flash教程:打造窗之恋音乐动画
相关文章      
本文评论
发表评论


点评: 字数
姓名:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款