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

PipesTest

PipesTest
* by ish-xxxx
Get Adobe Flash player
by ish_xxxx 22 Dec 2008
/**
 * PipesTest
 * by ish-xxxx
 */
package  {
	
	import flash.display.*;
	import flash.net.*;
	import flash.text.*;
	import flash.filters.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.system.*;
	import caurina.transitions.*;
	import caurina.transitions.properties.*;
	/**
	 * ...
	 * @author ish-xxxx
	 */
	public class App extends Sprite {
		
		//SWF SETTING CONSTANTS//////////////////
		private const BGCOLOR:uint = 0x666666;
		private const FRAMERATE:uint = 60;
		private const WIDTH:uint = 465;
		private const HEIGHT:uint = 465;
		///////////////////////////////////////////
		
		//SWF SETTING VARS/////////////////////////
		private var CANVAS:Graphics;
		///////////////////////////////////////////
		
		//CONSTANTS//////////////////////////////
		private const BASE_URL:String = "http://pipes.yahooapis.com/";
		private const API_URL:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=1nWYbWm82xGjQylL00qv4w&_render=rss&textinput1=japan";
		///////////////////////////////////////////
		
		//VARS////////////////////////////////////
		private var loader:URLLoader;
		private var data:XML;
		private var containers:Array = new Array();
		private var counter:uint = 0;
		private var l:uint;
		private var base_txt:TextField;
		///////////////////////////////////////////
		
		public function App() {
			
			//Security.loadPolicyFile( BASE_URL + "crossdomain.xml" );
			
			//CANVAS Setting////////////////////
			stage.frameRate = FRAMERATE;
			CANVAS = graphics;
			CANVAS.beginFill( BGCOLOR , 1.0 );
			CANVAS.drawRect( 0 , 0 , WIDTH , HEIGHT );
			CANVAS.endFill();
			////////////////////////////////////
			
			DisplayShortcuts.init();
			
			init();
			
		}
		
		private function init() : void {
			
			loader = new URLLoader();
			loader.addEventListener( Event.COMPLETE , function( ev:Event ) : void { onApiDataLoaded( XML( ev.target.data ) ) } );
			loader.addEventListener( IOErrorEvent.IO_ERROR , function( ev:IOErrorEvent ) : void { /**/ } );
			loader.load( new URLRequest( API_URL ) );
			
		}
		
		private function onApiDataLoaded( _data:XML ) : void {
			
			data = _data;
			var ran:uint = Utils.getRandom( data.channel.item.length() ) | 0;
			var elm:String = data.channel.item[ran].title;
			
			base_txt = new TextField();
			base_txt.text = elm;
			
			render( elm );
			
		}
		
		private  function render( src:String ) : void {
			
			var elms:Array = src.split( "" );
			l = elms.length;
			
			for ( var i:uint = 0 ; i < l ; i++ ) {
				var sp:Sprite = new Sprite();
				var tf:TextField = new TextField();
				tf.text = elms[i];
				tf.autoSize = TextFieldAutoSize.LEFT;
				tf.selectable = false;
				tf.antiAliasType = AntiAliasType.ADVANCED;
				var bmpd:BitmapData = new BitmapData( tf.width , tf.height , true , 0x00000000 );
				bmpd.draw( tf , null , null , null , null , true );
				var bmp:Bitmap = new Bitmap( bmpd , "auto" , true );
				sp.addChild( bmp );
				
				sp.x = Utils.getRandom( stage.stageWidth );
				sp.y = Utils.getRandom( stage.stageHeight );
				addChild( sp );
				sp.rotation = Utils.getRandom( 360 );
				sp.scaleX = sp.scaleY = 0;
				sp.alpha = 0;
				
				containers.push( { container:sp , bmp:bmp , tfWidth:base_txt.getCharBoundaries( i ).x} );
				tf = null;
				
				Tweener.addTween( sp , {  _scale : Utils.getRandom( 10 ) ,  alpha : 1 , time : 0 , delay : i / 10 + 1 , transition : "easeOutBack" , onComplete : count } );
				
			}
			
		}
		
		private function count() : void {
			
			if ( ++counter == containers.length ) {
				
				var cx:Number = 0;
				
				for ( var i:uint = 0 ; i < counter ; i++ ) {
					
					var sp:Sprite = containers[i].container;
					var bmp:Bitmap = containers[i].bmp;
					var tfWidth:Number = containers[i].tfWidth;
					var tx:Number = tfWidth;
					cx = tx;
					Tweener.addTween( sp , { x : tx , y : 0 , rotation : 0 ,  _scale : 1 , time : 0.5 , delay : i / 20 , transition : "easeOutBack" } );
					
				}
				
			}
			
		}
		
	}
	
}

///////////////////////////////////////////////
//Optional Classes
///////////////////////////////////////////////
import flash.filters.*;

class Utils {
	
	public function Utils() {
		//Can't Create Instance
	}
	
	public static function getColor() : uint {
		
		var ranR:String = String( uint( Math.random() * 255 | 0 ) );  
		var ranG:String = String( uint( Math.random() * 255 | 0 ) );  
		var ranB:String = String( uint( Math.random() * 255 | 0 ) );  
		var res:uint = uint( ranR + ranG + ranB );   
		return res;  
		
	}
	
	public static function getRandom( threshold:Number ) : Number {
		
		var res:Number;
		res = Math.random() * threshold;
		return res;
		
	}
	
	public static function getBlur() : BlurFilter {  
		
		var b:BlurFilter = new BlurFilter();  
		b.blurX = getRandom( 20 ) | 0;  
		b.blurY = getRandom( 20 ) | 0;  
		b.quality = BitmapFilterQuality.LOW;  

		return b;
		
	}  
	
}