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: Triangular Numbers

曲げて表示できないのかなあ
Get Adobe Flash player
by uwi 21 Oct 2009
/**
 * Copyright uwi ( http://wonderfl.net/user/uwi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4jtN
 */

// forked from shapevent's Triangular Numbers
package {

	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
    import flash.geom.*;

    // 曲げて表示できないのかなあ
	[SWF(width = 500, height = 500, frameRate=60)]

       public class Triangular extends Sprite {
		private var txt:TextField;
		private var txt2:TextField;
		private var count:int;

        private var text1 : Array;
        private var text2 : Array;

               public function Triangular(){

			txt = TextField(addChild(new TextField()));
			txt.defaultTextFormat = new TextFormat("_sans", 4, 0xcc3333, true, null);
			txt.width = stage.stageWidth / 3;
			txt.height = stage.stageHeight+150;
			txt.z = -250;
			txt.x = stage.stageWidth;
			txt.rotation = 60;
			
			count = 0;
			addEventListener(Event.ENTER_FRAME, onLoop);
			
			txt2 = TextField(addChild(new TextField()));
			txt2.defaultTextFormat = new TextFormat("_sans", 4, 0x3333cc, true, null);
			txt2.width = stage.stageWidth / 3;
			txt2.height = stage.stageHeight+150;
			txt2.z = -100;
			txt2.x = 0;
			txt2.rotation = -30;
			
            text1 = [];
            text2 = [];
               }
               // private methods

		private function onLoop(evt:Event):void{
		     count++;
		     text1.push(triangular(count).toString(2));
		     if(text1.length >= 200)text1.shift();
		     text2.push(square(count).toString(2));
		     if(text2.length >= 200)text2.shift();
		     txt.text = text1.join("\n");
			 txt.scrollV= txt.maxScrollV;
		     txt2.text = text2.join("\n");
			 txt2.scrollV= txt2.maxScrollV;
		}
		private function triangular(n:int):Number{
		       return (n * (n + 1)) / 2;
		}
		
		private function square(n:int):Number{
		       return n * n;
		}

       }

}