图片放大缩小移动类_Flash教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:Actionscript优化教程
在这篇文章中,我们讨论优化您的actionscript代码的各种不同方法,我们业已起用一套标准以测试典型的游戏代码和看看如何使FlashPlayer发挥最好的性能。代

-图片放大缩小移动类: -----------------------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;
};
//完成。


分享:数组排序方法介绍
数组排序sortsort方法把数组元素按一定的顺序重新排列,语法格式如下:myArray.sort([comparefunction])comparefunction是可选参数,假如不选用该参数,数

来源:设计前沿网上收集//所属分类:Flash教程/更新时间:2008-03-05
相关Flash教程