圖片放大縮小移動(dòng)類_Flash教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:Actionscript優(yōu)化教程在這篇文章中,我們討論優(yōu)化您的actionscript代碼的各種不同方法,我們業(yè)已起用一套標(biāo)準(zhǔn)以測(cè)試典型的游戲代碼和看看如何使FlashPlayer發(fā)揮最好的性能。代
-圖片放大縮小移動(dòng)類: -----------------------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---------------------------------------
//插入一張大于或者等于場(chǎng)景大小的圖片,按f8,頂點(diǎn)為左上角,位置為0,0.
圖片的實(shí)例名為:pic.
然后把以下復(fù)制到第一楨看效果:
//---------------------
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;
};
//完成。
分享:數(shù)組排序方法介紹數(shù)組排序sortsort方法把數(shù)組元素按一定的順序重新排列,語(yǔ)法格式如下:myArray.sort([comparefunction])comparefunction是可選參數(shù),假如不選用該參數(shù),數(shù)
相關(guān)Flash教程:
Flash教程Rss訂閱網(wǎng)站制作教程搜索
Flash教程推薦
- Flash AS數(shù)組學(xué)習(xí)
- Flash MX2004入門與進(jìn)階實(shí)例——元件和實(shí)例(14)
- Flash繪制小龍與花插畫場(chǎng)景
- Flash MX2004入門與進(jìn)階實(shí)例——?jiǎng)幼髂_本進(jìn)階(7)
- 高級(jí):Flash制作物體彈跳電腦游戲
- Flash MX2004入門與進(jìn)階實(shí)例--動(dòng)畫基礎(chǔ)(23)
- Flash制作四種3D隧道視覺(jué)動(dòng)畫效果
- 遮照及文字遮照的幾個(gè)概念和事例
- Flash高級(jí)應(yīng)用:用AS3調(diào)用攝像頭
- Flash MX2004入門與進(jìn)階實(shí)例——時(shí)間軸特效和行為(3)
- 相關(guān)鏈接:
- 教程說(shuō)明:
Flash教程-圖片放大縮小移動(dòng)類
。