Posted By

daisuke103 on 02/14/08


Tagged

image textmate filter Pic as2 lenz factory ball


Versions (?)

AS2 レンズフィルターのように画像を拡大して移動する


 / Published in: Other
 

  1. /*
  2. このスクリプトはattachされるインスタンスに書く
  3. これ以外に ID: ins_Lenzの90pxの正円で写真(pic)をマスクしたリンケージシンボルを作成
  4. */
  5.  
  6. num = 15;
  7. zr = 10;
  8. vx = 5;
  9. vy = 3;
  10. ballD = 150;
  11. boundary = [20, 20, 620, 360];
  12. R = ballD/2;
  13. boundary[0] += R;
  14. boundary[1] += R;
  15. boundary[2] -= R;
  16. boundary[3] -= R;
  17. scaleA = [];
  18. scaleB = [];
  19.  
  20. // 内側に行くほど拡大した写真をマスクしている
  21. for (i=1; i<=num; i++) {
  22. scaleA[i] = 10+90*(num+1-i)/num;
  23. scaleB[i] = 100+zr*i;
  24. this.attachMovie("ins_Lenz", "lenz_"+i, i);
  25. this["lenz_"+i]._xscale = this["lenz_"+i]._yscale=scaleA[i];
  26. this["lenz_"+i].pic._xscale = this["lenz_"+i].pic._yscale=100*scaleB[i]/scaleA[i];
  27. }
  28. //
  29. function f_ballMove() {
  30. this._x+vx;
  31. if (this._x+vx>boundary[2]) {
  32. this._x = boundary[2];
  33. vx *= -1;
  34. } else if (this._x+vx<boundary[0]) {
  35. this._x = boundary[0];
  36. vx *= -1;
  37. } else {
  38. this._x += vx;
  39. }
  40. if (this._y+vy>boundary[3]) {
  41. this._y = boundary[3];
  42. vy *= -1;
  43. } else if (this._y+vy<boundary[1]) {
  44. this._y = boundary[1];
  45. vy *= -1;
  46. } else {
  47. this._y += vy;
  48. }
  49. for (i=1; i<=num; i++) {
  50. this["lenz_"+i].pic._y = -1*scaleB[i]/scaleA[i]*this._y;
  51. this["lenz_"+i].pic._x = -1*scaleB[i]/scaleA[i]*this._x;
  52. }
  53. }
  54. f_ballMove();
  55.  

Report this snippet  

You need to login to post a comment.