用Actionscript3.0编写的伪3D文字旋转
程序代码如下(文档类)
package { import flash.display.MovieClip; import flash.display.Sprite; import flash.text.TextField; import flash.events.Event; public class sanDwenzixuanzhuan extends Sprite { private var dushu:Number=0; private var rx:Number=150;//半径 private var ry:Number=50;//半径 private var zs:Number=3;//转速 public function sanDwenzixuanzhuan() { // constructor code init(); } private function movexz(la:String,jiao:Number=0):Sprite { var sp:Sprite=new Sprite(); var lab:TextField=new TextField(); lab.text=la; //白色字体 lab.textColor=0xffffff; lab.width=20; sp.addChild(lab); addEventListener(Event.ENTER_FRAME,movetext); function movetext(ee:Event):void { //文字的位置 sp.x=250+rx*Math.cos(jiao*Math.PI/180); sp.y=200+ry*Math.sin(jiao*Math.PI/180); //使字体的透明度在正前方可见, sp.alpha=Math.cos(jiao*Math.PI/180-Math.PI/3); jiao-=zs; } return sp; } public function init():void { var _arr:Array=new Array("好","好","学","习","天","天","向","上","!"); for (var i:int=0;i<_arr.length;i++) { var s:Sprite=movexz(_arr[i],i*360/_arr.length); s.x=0; addChild(s); } } } }