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

var, const, static

Get Adobe Flash player
by bkzen 07 Jul 2010
    Embed
/**
 * Copyright bkzen ( http://wonderfl.net/user/bkzen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gPF6
 */

package {
	import flash.events.Event;
	import flash.utils.getTimer;
	import com.actionscriptbible.Example;
	import com.bit101.components.PushButton;
	public class Test extends Example {
		
		public const testA: int = 100;
		public static const testB: int = 100;
		public var testC: int = 100;
		public static var testD: int = 100;
		
		public function Test() {
			new PushButton(this,365,0,"test", onClick);
		}
		private function onClick(e:Event):void
		{
			var n: int = 1000;
			var t: int = getTimer();
			var testE: int = 100;
			const testF: int = 100;
			for (var i:int = 0; i < n; i++) 
			{
				for (var j:int = 0; j < n; j++) 
				{
					var addressA: int = i * 4 + j * n * testA;
					addressA + 1;
					addressA + 2;
					addressA + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressB: int = i * 4 + j * n * Test.testB;
					addressB + 1;
					addressB + 2;
					addressB + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressC: int = i * 4 + j * n * testC;
					addressC + 1;
					addressC + 2;
					addressC + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressD: int = i * 4 + j * n * Test.testD;
					addressD + 1;
					addressD + 2;
					addressD + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressE: int = i * 4 + j * n * testE;
					addressE + 1;
					addressE + 2;
					addressE + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressF: int = i * 4 + j * n * testF;
					addressF + 1;
					addressF + 2;
					addressF + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressG: int = i * 4 + j * n * testB;
					addressG + 1;
					addressG + 2;
					addressG + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressH: int = i * 4 + j * n * testD;
					addressH + 1;
					addressH + 2;
					addressH + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressI: int = i * 4 + j * n * Hoge.testI;
					addressI + 1;
					addressI + 2;
					addressI + 3;
				}
			}
			trace(getTimer() - t);
			t = getTimer();
			for (i = 0; i < n; i++) 
			{
				for (j = 0; j < n; j++) 
				{
					var addressJ: int = i * 4 + j * n * Hoge.testJ;
					addressJ + 1;
					addressJ + 2;
					addressJ + 3;
				}
			}
			trace(getTimer() - t);
			trace("---");
		}
	}
}

class Hoge
{
	public static const testI: int = 100;
	public static var testJ:int = 100;
}