Flash Views

FL • Tween 類別 - 圖片縮放效果 (AS2)

Flash CS3 logo
「Tween 類別」是 flash 內建的 ActionScript 動畫效果,
只要稍為修改一下參數即可套用在靜態的按鈕或MovieClip上面,
就會產生各種不同的影片片段移動、淡出及調整大小動態效果, 也能讓您指定多種加/減速方法。
「加/減速」是指在動畫進行時的逐漸加速或減速,可以讓動畫更具真實感。
提供許多加/減速方法都有這種加速和減速的方程式,加/減速動畫將根據這些方程式而變更。

例如:

import mx.transitions.Tween;
import mx.transitions.easing.*;
//參數:物件,屬性,漸變函式,起始值,結束值,持續影格或秒數,使用秒數與否
new Tween(test_mc, "x", Elastic.easeOut, 0,200, 2,true);


範列效果:

import mx.transitions.Tween;
import mx.transitions.easing.*;
//預先載入「Tween 類別」程式
var endX:Number = 504;
var endY:Number = 312;
var beginX:Number;
var beginY:Number;
var prev_obj;
var prev_x;
var prev_y;
function BIG_SMALL(_mc) {
   if (prev_obj != _mc && BIGorSMALL == 1){
       new Tween(prev_obj, "_xscale", Regular.easeOut, 160, 100, 2, true);
       //設定 tween 所有參數,被選取物件使用 Tween 類別控制縮放屬性,從 100% 放大到 150% 的大小
      new Tween(prev_obj, "_yscale", Regular.easeOut, 160, 100, 2, true);
      new Tween(prev_obj, "_x", Regular.easeOut, endX, prev_x, 2, true);
      new Tween(prev_obj, "_y", Regular.easeOut, endY, prev_y, 2, true); 
      BIGorSMALL = 0;


 }
 
 prev_obj = _mc;
 prev_x = _mc._x;
 prev_y = _mc._y;
  
 _mc.swapDepths(999); //將被選取物件的 depth 深度向上推到 999 的位置
 if (!BIGorSMALL == 1) {
     _root.beginX = _mc._x;
     _root.beginY = _mc._y;
     BIGorSMALL = 1;
     new Tween(_mc, "_xscale", Regular.easeOut, 100, 160, 2, true);
     new Tween(_mc, "_yscale", Regular.easeOut, 100, 160, 2, true);
     new Tween(_mc, "_x", Regular.easeOut, beginX, endX, 2, true);
     new Tween(_mc, "_y", Regular.easeOut, beginY, endY, 2, true);
} else {
     BIGorSMALL = 0;
     new Tween(_mc, "_xscale", Regular.easeOut, 160, 100, 2, true);
     new Tween(_mc, "_yscale", Regular.easeOut, 160, 100, 2, true);
     new Tween(_mc, "_x", Regular.easeOut, endX, beginX, 2, true);
     new Tween(_mc, "_y", Regular.easeOut, endY, beginY, 2, true);
   }
}

function set_prev_xy(which){ 
     prev_x = which._x;
     prev_y = which._y;
}

_root.AA_mc.onRelease = function() { 
     BIG_SMALL(this);

};
_root.BB_mc.onRelease = function() { 
     BIG_SMALL(this);
};
_root.CC_mc.onRelease = function() {
     BIG_SMALL(this);
};
_root.DD_mc.onRelease = function() {
     BIG_SMALL(this);
};



程式說明:

其中藍色的參數是「加/減速類別」,就是不同的動態效果,有幾種不同的類型可以變換,說明如下:

1. Back:在轉換範圍的一端或兩端延伸動畫,以提供從範圍以外拉回的效果。
2. Bounce:完全在轉換範圍內,對一或兩端加入跳躍的效果。跳躍的數目與時間關聯:較長的時間會產生更多跳躍。
3. Elastic:加入落到轉換範圍外一或兩端的彈跳效果。彈跳量不受時間影響。
4. Regular:在一或兩端加入更為緩慢移動。這個功能可讓您加入加速效果、減速效果或兩者。
5. Strong:在一或兩端加入更為緩慢移動。這個效果類似於 Regular 加/減速類別,不過更為顯著。


在「加/減速類別」的後面是設定「加/減速方法」:

1. easeIn:只有在動作開始時才顯示動態效果。
2. easeOut:只有在動作結束時才顯示動態效果。
3. easeInOut:在在動作的開始和結束時都顯示動態效果


如果您喜歡我的文章,請在文章最末按5下Like!

You Might Also Like

0 意見

純粹分享麥子購買產品!
文筆絕對不好,請噴子勿噴