| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 网页制作 > Flash教程 > ActionScript教程 > 文章正文 用户登录
图片链接移动代码
将图片作为博客介
将图片作为文章栏
图片滤镜的效果
做图片站电影站赚
做图片站电影站赚
xml方式载入图片自
flash中实现js的图
实现导入外部JPG图
怎样在FLASH里调用

图片放大缩小移动类           

图片放大缩小移动类

作者:佚名 来源:闪吧 作者: ycccc8202 更新:2007-1-13 20:49:13 错误报告 我要投稿

-图片放大缩小移动类:
-----------------------class-------------------------

class ZoomOpenMove {
   private var obj:MovieClip;
   private var pos_scale:Number;
   private var x_speed:Number;
   private var y_speed:Number;
   private var scale_speed:Number;
   private var scale_step:Number;
   public function ZoomOpenMove(_obj:MovieClip) {
      this.obj = _obj;
   }
   public function get s_speed():Number {
      return scale_speed;
   }
   public function set s_speed(_s_speed:Number):Void {
      scale_speed = _s_speed;
   }
   public function get _x_speed():Number {
      return x_speed;
   }
   public function set _x_speed(_x_x_speed:Number):Void {
      x_speed = _x_x_speed;
   }
   public function get _y_speed():Number {
      return y_speed;
   }
   public function set _y_speed(_y_y_speed:Number):Void {
      y_speed = _y_y_speed;
   }
   public function get _scale_step():Number {
      return scale_step;
   }
   public function set _scale_step(scalestep:Number):Void {
      scale_step = scalestep;
   }
   public function get _scale_speed():Number {
      return scale_speed
   }
   public function set _scale_speed(scalespeed:Number):Void {
      scale_speed = scalespeed
   }
   public function get _pos_scale():Number {
      return pos_scale;
   }
   public function set _pos_scale(posscale:Number):Void {
      pos_scale = posscale;
   }
   public function Open() {
      if (_root._xmouse<Stage.width and _root._xmouse>0 and _root._ymouse>0 and _root._ymouse<Stage.height) {
         obj._xscale<pos_scale ? obj._xscale=obj._yscale += scale_step : obj._xscale=obj._yscale=pos_scale;
      }
   }
   public function Zoom() {
      if (_root._xmouse<Stage.width and _root._xmouse>0 and _root._ymouse>0 and _root._ymouse<Stage.height) {
         obj._x += (0-obj._x)/scale_speed;
         obj._y += (0-obj._y)/scale_speed;
         obj._xscale += (100-obj._xscale)/scale_speed;
         obj._yscale += (100-obj._yscale)/scale_speed;
      }
   }
   public function Move() {
      if (obj.hitTest(_root._xmouse, _root._ymouse, true)) {
         var pos_x = _root._xmouse*(Stage.width-obj._width)/Stage.width;
         var pos_y = _root._ymouse*(Stage.height-obj._height)/Stage.height;
         obj._x += (pos_x-obj._x)/x_speed;
         obj._y += (pos_y-obj._y)/y_speed;
      }
   }
}
//------------------------------------fla---------------------------------------

//插入一张大于或者等于场景大小的图片,按f8,顶点为左上角,位置为0,0.

图片的实例名为:pic.

然后把以下复制到第一桢看效果:

//---------------------

var newzom:ZoomOpenMove = new ZoomOpenMove(pic);
newzom._x_speed = newzom._y_speed=9;
newzom._pos_scale = 300;
newzom._scale_speed = 9;
press = 0;
onMouseDown = function () {
   press = 1;
   this.Oldtime = getTimer();
   this.onEnterFrame = function() {
      this.Newtime = getTimer();
      this.preTime = this.Newtime-this.Oldtime;
      newzom._scale_step = this.preTime/400;
      newzom.Move();
      press ? newzom.Open() : newzom.Zoom();
   };
};
onMouseUp = function () {
   press = 0;
};
//完成。

   //是把原来从闪吧学到的,加以应用写成类。
点击浏览该文件
//建议保存下来看

文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。