Posted By

daisuke103 on 02/11/08

AS2 ãƒžã‚¦ã‚¹ã«ã‚ˆã£ã¦ä½ç½®ãŒå¤‰ã‚ã‚‹æ“¬ä¼¼3Då›žè»¢

/ Published in: Other

1. /*
2. author page::
3. http://www.trick7.com/blog/2006/07/05-160520.php
4. ãƒžã‚¦ã‚¹ã®ä½ç½®ã«ã‚ˆã£ã¦å›žè»¢
5. ãƒªãƒ³ã‚±ãƒ¼ã‚¸å: rect ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’ç”¨æ„
6. xmlã‚’ä½¿ã†æ™‚ã¯
7. rectNum = xmlObject.length;ã¨ã—ã¦
8. init()ã‚’xmlãƒ­ãƒ¼ãƒ‰å¾Œã«å®Ÿè¡Œ
9. */
10.
11.
12. //--- â†“src ---
13.
14.
15. import flash.geom.ColorTransform;
16.
17. //Vanishing Pointï¼ˆæ¶ˆå¤±ç‚¹ï¼‰
18. var vpX = Stage.width/2;
19. var vpY = Stage.height/2;
21. var rectNum:Number = 20;
22. //ä¸­å¿ƒè»¸ã¨é…ç½®ã™ã‚‹ãƒ ãƒ¼ãƒ“ãƒ¼ã‚¯ãƒªãƒƒãƒ—ã¨ã®è·é›¢
24. //Focal Lengthï¼ˆç„¦ç‚¹è·é›¢ï¼‰
25. var fl:Number = 250;
26.
27. init();
28. function init():Void {
29. for (var i:Number = 0; i<rectNum; i++) {
30. var rect:MovieClip = attachMovie("rect", "rect"+i, i);
31. var angleInitY:Number = (360/rectNum)*i;
33. angleInitY = angleInitY*Math.PI/180;
34. var cosInitY:Number = Math.cos(angleInitY);
35. var sinInitY:Number = Math.sin(angleInitY);
38. rect.x = initX1;
39. rect.y = 0;
40. rect.z = initZ1;
41. rect.number.text=i
42. //pall.swapDepths(0)//ä¸­å¿ƒæ£’ã‚’é€šã™
43. }
44. }
45. function onEnterFrame():Void {
47. for (var i:Number = 0; i<rectNum; i++) {
48. var rect:MovieClip = this["rect"+i];
49. var angleY:Number = (_xmouse-vpX)*0.001;
50. var cosY:Number = Math.cos(angleY);
51. var sinY:Number = Math.sin(angleY);
52. var angleX:Number = (_ymouse-vpY)*0.001;
53. var cosX:Number = Math.cos(angleX);
54. var sinX:Number = Math.sin(angleX);
55.
56. var x1:Number = rect.x*cosY-rect.z*sinY;
57. var z1:Number = rect.z*cosY+rect.x*sinY;
58. var y1:Number = rect.y*cosX-z1*sinX;
59. var z2:Number = z1*cosX+rect.y*sinX;
60.
61. rect.x = x1;
62. rect.y = y1;
63. rect.z = z2;
64. var scale = fl/(fl+rect.z);
65. rect._xscale = rect._yscale=scale*100;
66. rect._x = vpX+(rect.x*scale);
67. rect._y = vpY+(rect.y*scale);
68. //zã®å€¤ã‚’ã‚‚ã¨ã«ã€é‡ãªã‚Šé †ã‚’èª¿æ•´
69. rect.swapDepths(-rect.z);
70. //å¥¥ã®ãƒ ãƒ¼ãƒ“ãƒ¼ã‚¯ãƒªãƒƒãƒ—ã®æ˜Žåº¦ã‚’ä¸‹ã’ã‚‹
71. var val = Math.min(-5*Math.sqrt(z2),0);
72. rect.transform.colorTransform = new ColorTransform(1, 1, 1, 1, val, val, val, 0);
73. }
74. }
75. }