//飞碟
import flash.display.Sprite; import flash.utils.Timer; import flash.events.TimerEvent; var B:Sprite=new Sprite(); addChild(B); B.x = stage.stageWidth / 2; B.y = stage.stageHeight / 2; for (var i:int=0; i<9; i++) { var bg:Sprite=new Sprite(); addChild(bg); bg.graphics.drawCircle(0,0,400); bg.x = 200; bg.y = i * 20; for (var j:int=0; j<=36; j++) { bg.graphics.beginFill(Math.random()*0xFFFFFF); i<5?bg.graphics.drawCircle(i*50*Math.cos(Math.PI/180*j*10),i*50*Math.sin(Math.PI/180*j*10),5):bg.graphics.drawCircle((8-i)*50*Math.cos(Math.PI/180*j*10),(8-i)*50*Math.sin(Math.PI/180*j*10),5); bg.graphics.endFill(); } bg.rotationX = -80; B.addChild(bg); } var timer:Timer = new Timer(50); timer.start(); timer.addEventListener(TimerEvent.TIMER,timerhs); function timerhs(ev:TimerEvent):void { B.rotationY -= 5; B.rotationX -= 2; ev.updateAfterEvent(); }
效果二:八卦图
import flash.utils.Timer; import flash.events.TimerEvent; import flash.display.Sprite; import flash.geom.Point; import flash.filters.GlowFilter; var sp:Sprite=new Sprite(),ro:int=90; sp.x = stage.stageWidth / 2,sp.y = stage.stageHeight / 2; addChild(sp); sp.graphics.lineStyle(20,0x666666); sp.graphics.moveTo(0,200); var tA:Timer = new Timer(10); tA.start(); tA.addEventListener(TimerEvent.TIMER,ontArun); function ontArun(ev:TimerEvent):void { if (tA.currentCount <= 180) { sp.graphics.lineTo(200*Math.cos(Math.PI/180*ro),200*Math.sin(Math.PI/180*ro)); } else if (tA.currentCount<=270) { sp.graphics.lineTo(100*Math.cos(Math.PI/180*ro),100+100*Math.sin(Math.PI/180*ro)); } else if (tA.currentCount <=360) { sp.graphics.lineTo(100*Math.cos(Math.PI/180*ro),-100+100*Math.sin(Math.PI/180*-ro)); } if (tA.currentCount == 400) { sp.graphics.drawCircle(0,-100,10); sp.graphics.drawCircle(0,100,10); } ro += 2; sp.rotation += 5; ev.updateAfterEvent(); }