In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: Textを球状に配置するだけ

fork fork fork 
SpriteにTextFieldを加えて球状に配置しただけです。
stageクリックで配置をランダムにします。
Z-sortはclockmakerさんのものを利用させてもらってます
(http://wonderfl.kayac.com/code/32ddf17fbf8581122c192435d1cccc870d10b375)。
Get Adobe Flash player
by hacker_wownhzo3 30 Jul 2009
    Embed
/**
 * Copyright hacker_wownhzo3 ( http://wonderfl.net/user/hacker_wownhzo3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wP5q
 */

// forked from hacker_57o638hu's forked from: Textを球状に配置するだけ
// forked from teageek's Textを球状に配置するだけ
// forked from sake's Spriteを球状に配置するだけ
/*
  fork fork fork 
   SpriteにTextFieldを加えて球状に配置しただけです。
   stageクリックで配置をランダムにします。
   Z-sortはclockmakerさんのものを利用させてもらってます
   (http://wonderfl.kayac.com/code/32ddf17fbf8581122c192435d1cccc870d10b375)。
*/


package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.Matrix3D;
        import flash.text.*;
        import flash.events.*;
        import caurina.transitions.Tweener;
        
	[SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="40")]

	public class SpriteSphere extends Sprite
	{
		private var container:Sprite;
		private var planeN:Number;
		private const planeW:Number=5;
		private const planeH:Number=50;
		private const radius:Number=150;
                private const s:String="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                

		public function SpriteSphere()
		{
			container = new Sprite();
			container.x = 465 / 2;
			container.y = 465 / 2;
			addChild(container);

			planeN=0;
			var H:int = (2 * radius * Math.PI) / 2 / planeH;
			var theta1: Number;
			var theta2: Number=90;
                        var c:int = 0;
                        stage.addEventListener(MouseEvent.CLICK, function():void{
                            var deleteNum:uint = container.numChildren;
                            trace(deleteNum);
                                for (var i:int = 0; i < deleteNum; i++) 
                                {var child:* = container.getChildAt(i);   
                                   
                    Tweener.addTween(child,{
                        x: Math.floor(Math.random() * 301) - 150,
                        z: Math.floor(Math.random() * 301) - 150,
                        y: Math.floor(Math.random() * 301) - 150,
                        time:3,
                                  transition:"easeinquad"});    
                   Tweener.addTween(child,{delay:5,onComplete:function():void{
                     container.removeChild(this);}});
                      


                
                                  }               
                                        });

			for(var i:int = 0; i < H; i++)
			{
				theta1 = 0;
				var pn:int = Math.floor((2 * radius * Math.cos(theta2 * Math.PI / 180) * Math.PI) / planeW);
				for(var j:int = 0; j < pn; j++)
				{   
                                        var tf:TextField = new TextField();
                                        tf.defaultTextFormat = new TextFormat("typeWriter_",30, 0x0);
                                        tf.text = s.charAt(c++); if(c>25)c=0;
                                        tf.autoSize = TextFieldAutoSize.LEFT;
                                        tf.x=-25;
                                        tf.y=-25;
                                        tf.textColor= 0xffffff*Math.random();   
                                        tf.selectable=false;  
                                            
					var sp:Sprite=new Sprite;
					//sp.graphics.beginFill(Math.random() * 0xffffff, 0.7);
					//sp.graphics.drawEllipse(-planeW / 2, -planeH / 2, planeW, planeH);
					//sp.graphics.endFill();
					sp.addChild(tf);
                                        sp.rotationX=-theta2;
					sp.rotationY=theta1;
					sp.x=radius * Math.cos(theta2 * Math.PI / 180) * Math.sin(theta1 * Math.PI / 180);
					sp.y=radius * Math.sin(theta2 * Math.PI / 180);
					sp.z=radius * Math.cos(theta2 * Math.PI / 180) * Math.cos(theta1 * Math.PI / 180);
					theta1+=360 / pn;
					sp.name="sp" + planeN.toString();
					container.addChild(sp);
					planeN++;
				}
				theta2-=180 / H;
			}

			addEventListener(Event.ENTER_FRAME, onFrame);
		}

		private function onFrame(e:Event):void
		{
			container.rotationY++;

			var array:Array=[];

			for(i=0; i < planeN; i++)
			{
				var sp:Sprite=container.getChildByName("sp" + i.toString())as Sprite;
				var mat:Matrix3D=sp.transform.getRelativeMatrix3D(this);
				array.push({sp:sp, z:mat.position.z});
			}

			array.sortOn("x", Array.NUMERIC | Array.DESCENDING);

			for(var i:int=0; i < planeN; i++)
			{
				var sp:Sprite=array[i].sp as Sprite;
				container.setChildIndex(sp, i);

				var b:Number=(array[i].z as Number) / 14;
				sp.filters=(b > 4) ? [new BlurFilter(b, b, 3)] : [];
			}
		}
	}
}