ã«ã«ã¼ã»ã«ã¢ã¯ã·ã§ã³
åéåãåé¢ããè¦ããããªå¥¥è¡ãæã®ããåãããã¦ã¹ã§å¶å¾¡ããã¢ã¯ã·ã§ã³ã®ä½ãæ¹ã§ã
解説ã¯ã¤ã¥ããã
æ°è¦ãã¡ã¤ã«ä½æ
ã¹ãã¼ã¸è¨å®ã¯ãµã¤ãºã400Ã300ããã¬ã¼ã ã¬ã¼ãã¯30ã«
ã¾ãã¯èæ¯ãä½æ
400Ã180ã®ç©å½¢ãæããã¹ãã¼ã¸ã®ä¸ã«é
ç½®
ç·ã¯ãªãã#FFFFFFãã#CCCCCCã®è²ã§ç·å½¢ã°ã©ãã¼ã·ã§ã³
æ°è¦ã·ã³ãã«ãä½æ
ActionScriptã«æ¸ãåºãã«ãã§ãã¯ãå
¥ãã¦ãã¯ã©ã¹åãPanelã«
ç©å½¢ããªããã£ããã¼ã«ã§ç»åã®ãããªå³å½¢ãæã
å¡ãã¯#CCCCCCãã#999999ã®è²ã§ä¸ããä¸ã«ç·å½¢ã°ã©ãã¼ã·ã§ã³
æ°è¦ã¬ã¤ã¤ã¼ã追å ããActionScriptãè¨è¿°
èãæ¹ã¨ãã¦ã¯以前の記事ã¨åãããã«ãä»®ã®åº§æ¨ãè¨å®ãã¦ããããXãY座æ¨ãå²ãåºã
//panelã®ææ° var num:int = 9; //è¦ç·ä½ç½® var xEye:int = stage.stageWidth/2; var yEye:int = 70; //Y軸æ¹å(çä¸)ããè¦ãã¨ãã®åã®åå¾ var radius:int = 150; //è¦ç¹ããåã®ä¸å¿ã¾ã§ã®Z軸æ¹åè·é¢ var cLength:int = 500; var angle:Number = 0; //è§åº¦ var speed:Number; //é度 var panels:Array = new Array(); //panelåæè¨å® for (var i:int = 0; i<num; i++) { //panelãçæãã¦é åã«æ ¼ç´ãé ç½® panels.push(new Panel()); addChild(panels[i]); //ä»®æ³X軸ãY軸ãZ軸ã§ã®panelã®åæä½ç½® panels[i].xPos = radius*Math.cos(i/num*Math.PI*2); panels[i].yPos = 100; panels[i].zPos = radius*Math.sin(i/num*Math.PI*2); //panelã®éæ度ã0.7ã« panels[i].alpha = 0.7; //ãã¦ã¹ã«ã¼ã½ã«ãæã®å½¢ã« panels[i].buttonMode = true; //ãã¦ã¹ãªã¼ãã¼ã¤ãã³ã追å panels[i].addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); //ãã¦ã¹ã¢ã¦ãã¤ãã³ã追å panels[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); } //panelã®åãã®ã¤ãã³ã追å addEventListener(Event.ENTER_FRAME, moveCarousel); function moveCarousel(e:Event):void { //X軸æ¹åã®ãã¦ã¹ä½ç½®ã«ãã£ã¦é度å¤æ´ speed = (mouseX-xEye)/3000; //é度ãå ç®ãã¦è§åº¦å¤æ´ angle += speed; for (i = 0; i<num; i++) { //angleãå¤åããã¦panelã®ä»®æ³X軸ãZ軸ã§ã®ä½ç½®ãå¤ãã panels[i].xPos = radius*Math.cos(angle+i/num*Math.PI*2); panels[i].zPos = radius*Math.sin(angle+i/num*Math.PI*2); //panelã®Z軸æ¹åä½ç½®ã®æ¯ç var zRatio = cLength/(cLength+panels[i].zPos); //ä»®æ³ä½ç½®ãã¹ãã¼ã¸ä¸ã®XãY座æ¨ã«å¤æ panels[i].x = xEye+panels[i].xPos*zRatio; panels[i].y = yEye+panels[i].yPos*zRatio; //Z軸æ¹åä½ç½®ã«ãã£ã¦panelã®å¤§ããå¤æ´ panels[i].scaleX = panels[i].scaleY = zRatio; //trace(myArray[i].name); } //éãé ãå¤æ´ããããã®é¢æ°å®è¡ sortPanel(); } function sortPanel():void { //é åãä»®æ³Z軸ä½ç½®ã奥ã«ããé ã«ä¸¦ã³æ¿ã panels.sortOn("zPos", Array.NUMERIC | Array.DESCENDING); for (i = 0; i<num; i++) { //éãé ãå¤æ´ãèæ¯ãããã®ã§+1 setChildIndex(panels[i], i+1); } } function mouseOverHandler(e:Event):void { //panelã®åããæ¢ãã¦éæ度ã1ã« removeEventListener(Event.ENTER_FRAME, moveCarousel); e.target.alpha = 1; } function mouseOutHandler(e:Event):void { //åã³panelã®åãã追å ãã¦ãéæ度0.7ã« addEventListener(Event.ENTER_FRAME, moveCarousel); e.target.alpha = 0.7; }
ããã§ã ã¼ãã¼ãã¬ãã¥ã¼ããã¨ä»¥ä¸ã®ããã«ãªã£ã¦ããã¨æãã¾ã
以ä¸ãã«ã«ã¼ã»ã«ã¢ã¯ã·ã§ã³ã®ä½ãæ¹ã§ãã