⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 array2.as

📁 swf 解码源程序, 纯C代码
💻 AS
字号:
// makeswf -v 6 -r 1 -o array2-6.swf array2.as// makeswf -v 7 -r 1 -o array2-7.swf array2.as// TODO: version 5 compatible version, inserting and reading, sorton// define our own function to print arrays, that shows nested arrays nicelyfunction pretty (arr, lvl) {  var i;  var str = "[";  for (i = 0; i < arr.length; i++) {    if (arr[i] != null && arr[i].constructor == Array) {      str = str + pretty (arr[i], lvl + 1);    } else {      str = str + arr[i];    }    if (i != arr.length - 1)      str += ", ";  }  str += "]";  return str;}function mytrace (arr) {  if (arr != null && arr.constructor == Array) {    trace (pretty (arr, 0));  } else {    trace (arr);  }}mytrace ("## Static properties");mytrace (Array.CASEINSENSITIVE);mytrace (Array.DESCENDING);mytrace (Array.UNIQUESORT);mytrace (Array.RETURNINDEXEDARRAY);mytrace (Array.NUMERIC);old = Array.NUMERIC;Array.NUMERIC = 3;mytrace (Array.NUMERIC);Array.NUMERIC = old;mytrace (Array.NUMERIC);mytrace ("## Contructor");mytrace ("# Normal usage");mytrace (new Array ());				// empty arraymytrace (new Array (5));			// array with 5 empty spotsmytrace (new Array (1, "b", new Object ()));	// array with 3 pre-determined elementsmytrace (Array ());mytrace (Array (5));mytrace (Array (1, "b", new Object ()));mytrace ([]);mytrace ([1, "b", new Object ()]);mytrace ("# Special cases");mytrace (new Array (1000));			// big numbermytrace (new Array (-4));				// negative number as argumentmytrace (new Array ("3"));			// one string preseting number as argumentmytrace (new Array (new String (3)));		// one string preseting number as argumentmytrace (new Array (new Number (3)));		// number, but not a primitive typemytrace (new Array (3.5));			// floating point numbersmytrace (new Array (3.4));mytrace (new Array (3.6));mytrace (new Array ([], ["a", "b", [1, 2]]));	// nested arraysmytrace ("## length");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);mytrace (a.length);a = new Array (1, new Object (), "c");mytrace (a.length);a = new Array (1337);mytrace (a.length);a = new Array ();mytrace (a.length);mytrace (a);a.length = 10;mytrace (a.length);mytrace (a);mytrace ("# Special cases");a = new Array ();			// making it smaller than largest valuea.length = 10;a[9] = 1;mytrace (a);a.length = 5;mytrace (a);mytrace (a[9]);a.length = 10;mytrace (a);a = new Array (1, "b", "c", 4);		// negative valuea.length = -4;mytrace (a);mytrace (a.length);a = new Array ();			// setting negative variable while negative lengtha.length = -4;a[-2] = "x";mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);		// floating point valuesa.length = 3.4;mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);		// floating point valuesa.length = 3.5;mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);		// floating point valuesa.length = 3.6;mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);		// non-numeric valuesa.length = new Object ();mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);a.length = "har";mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);a.length = "3";mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);a.length = null;mytrace (a);mytrace (a.length);a = new Array (1, "b", "c", 4);a.length = undefined;mytrace (a);mytrace (a.length);mytrace ("## toString");mytrace ("# Normal usage");a = new Array ("a", "b", "c");mytrace (a.toString ());mytrace ("# Special cases");a = new Array ();			// empty arraymytrace (a.toString ());a = new Array (20);			// only undefined valuesmytrace (a.toString ());mytrace ("## join");mytrace ("# Normal usage");a = new Array ("a", "b", "c");mytrace (a.join ());			// default delimeter: ,mytrace (a.join (":"));			// custom delimetermytrace ("# Special cases");a = new Array ();			// empty arraymytrace (a.join ());mytrace (a.join (":"));a = new Array (1, "b", 3);mytrace (a.join (31));			// non-string parametersmytrace (a.join (new Object ()));mytrace (a.join (null));mytrace (a.join (undefined));mytrace (a.join ("lal", 31));		// many parametersmytrace (a.join (new Object (), 3, 3));a = new Array (20);			// only undefined valuesmytrace (a.join ());mytrace (a.join (":"));mytrace ("## Push");mytrace ("# Normal usage");a = new Array (1, 2, 3);mytrace (a.push (4));mytrace (a);mytrace (a.push ("a"));mytrace (a);mytrace ("# Special cases");a = new Array (1, 2, 3);mytrace (a.push (4, 5));		// more than one elementmytrace (a);mytrace (a.push ());			// pushing nothingmytrace (a);mytrace (a.push (["a", "b", "c"]));	// pushing another arraymytrace (a);a = new Array ();			// pushing when weird lengtha.length = "weird";mytrace (a.push ("weirder"));mytrace (a["weird"]);mytrace (a);a = new Array ();			// pushing nothing, weird lengtha.length = "weird";mytrace (a.push ());mytrace (a["weird"]);mytrace (a);a = new Array ();			// pushing on empty arraymytrace (a.push (6));mytrace (a);a = new Array (5);			// pushing on array with only undefined valuesmytrace (a.push (6));mytrace (a);a = new Array ();			// pushing on array with negative lengtha.length = -3;mytrace (a.push ("x"));mytrace (a[-3]);mytrace (a.length);mytrace ("## Pop");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);mytrace (a.pop ());mytrace (a);mytrace (a.pop ());mytrace (a);mytrace ("# Special cases");a = new Array ();			// emptymytrace (a.pop ());mytrace (a);a = new Array ();			// empty, weird lengtha.length = "weird";mytrace (a.pop ());mytrace (a);a = new Array (1, "b", "c", 4);		// use parametersmytrace (a.pop (5));mytrace (a);mytrace (a.pop ("c", "b"));mytrace (a);mytrace ("## Unshift");mytrace ("# Normal usage");a = new Array (1, 2, 3);mytrace (a.unshift (4));mytrace (a);mytrace (a.unshift ("a"));mytrace (a);mytrace ("# Special cases");a = new Array (1, 2, 3);mytrace (a.unshift (4, 5));		// more than one elementmytrace (a);mytrace (a.unshift ());			// unshifting nothingmytrace (a);a1 = new Array ("a", "b", "c");		// unshifting another arraymytrace (a.unshift (a1));mytrace (a);a = new Array ();			// unshifting on empty arraymytrace (a.unshift (6));mytrace (a);a = new Array (5);			// unshifting on array with only undefined valuesmytrace (a.unshift (6));mytrace (a);mytrace ("## Shift");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);mytrace (a.shift ());mytrace (a);mytrace (a.shift ());mytrace (a);mytrace ("# Special cases");a = new Array ();			// emptymytrace (a.shift ());mytrace (a);a = new Array (1, "b", "c", 4);	// use parametersmytrace (a.shift (5));mytrace (a);mytrace (a.shift ("b", "c"));mytrace (a);mytrace ("## Reverse");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);mytrace (a.reverse ());mytrace (a);a = new Array (1, new Object (), "c");mytrace (a.reverse ());mytrace (a);mytrace ("# Special cases");a = new Array ();			// emptymytrace (a.reverse ());mytrace (a);a = new Array ("a");			// one elementmytrace (a.reverse ());mytrace (a);a1 = new Array ([a, "b"]);		// array inside arraymytrace (a1.reverse ());mytrace (a1);a = new Array (1, "b", "c", 4);		// use parametersmytrace (a.reverse (4));mytrace (a);a = new Array (1, "b", "c", 4);mytrace (a.reverse ("b", "c"));mytrace (a);mytrace ("## Concat");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);a1 = new Array (1, new Object (), "c");mytrace (a.concat (a1));mytrace (a);mytrace (a1);a = new Array (1, "b", "c", 4);mytrace (a.concat (1, new Object (), "c"));mytrace (a);mytrace ("# Special cases");a = new Array ();			// empty arraysa1 = new Array ();mytrace (a.concat (a1));mytrace (a);mytrace (a1);a = new Array (1, "b", "c", 4);		// selfmytrace (a.concat (a));mytrace (a);a = new Array (1, ["b", "c"], 4);	// nested arraysa1 = new Array ([1, new Object ()], "c");mytrace (a.concat (a1));mytrace (a);mytrace (a1);mytrace ("## Slice");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);mytrace (a.slice (1, 3));mytrace (a);mytrace (a.slice (0, -2));mytrace (a);mytrace (a.slice (-2));mytrace (a);mytrace ("# Special cases");a = new Array (1, "b", "c", 4);		// empty arraymytrace (a.slice ());mytrace (a);a = new Array (1, "b", "c", 4);mytrace (a.slice ());			// without parametersmytrace (a);mytrace (a.slice (0, -2, 4, 3, "d"));	// with extra parametersmytrace (a);mytrace (a.slice (3, 20));		// with too much plusmytrace (a);mytrace (a.slice (20));mytrace (a);mytrace (a.slice (0, -5));		// with too much minusmytrace (a);mytrace (a.slice (-20));mytrace (a);mytrace (a.slice (1, 2, 3, 4, 5));	// extra parametersmytrace (a);mytrace (a.slice (1, 2, "hah", new Object ()));mytrace (a);mytrace ("## Splice");mytrace ("# Normal usage");a = new Array (1, "b", "c", 4);mytrace (a.splice (1));mytrace (a);a = new Array (1, "b", "c", 4);mytrace (a.splice (0, 1));mytrace (a);a = new Array (1, "b", "c", 4);mytrace (a.splice (-3, 2, new Object (), 3));mytrace (a);mytrace ("# Special cases");a = new Array ();			// empty arraymytrace (a.splice (0));mytrace (a);mytrace (a.splice (0, 0, "a", "b"));mytrace (a);// TODOmytrace ("## Sort");// not all things can be tested by tracing, because it's possible to have many valid// results that look the same, for example for: ["a", "A"].sort (Array.CASEINSENSITIVE)function sortall (arr, func, must, mustnot) {  for (i = 0; i < Array.NUMERIC * 2; i++) {    if ((must == 0 || (i & must) == must) && (mustnot == 0 || (i & mustnot) == 0)) {      var arr_copy = arr.concat ();      if (func != null) {	mytrace ("sort customfunc " + i + " " + pretty (arr, 0));	mytrace (arr_copy.sort (func, i));      } else {	mytrace ("sort " + i + " " + pretty (arr, 0));	mytrace (arr_copy.sort (i));      }      mytrace (arr_copy);    }  }}function compare_array_length (a, b) {  if (a.length > b.length) {    return 1;  } else if (a.length < b.length) {    return -1;  } else {    return 0;  }}mytrace ("# Normal usage");a = new Array ("a", "B", "c", "v", 1, 9, 10);sortall (a, null, 0, 0);a = new Array ();a[1] = 1;a[3] = "a";a[4] = 10;a[5] = "B";a[10] = "c";a[12] = 9;a[15] = "v";sortall (a, null, 0, Array.RETURNINDEXEDARRAY);a = new Array ("a", "B", "c", 1, 9, 10, "c");sortall (a, null, Array.UNIQUESORT, 0);a = new Array ("a", "B", "c", 1, 9, 10, "C");sortall (a, null, Array.UNIQUESORT | Array.CASEINSENSITIVE, 0);sortall (a, null, 0, Array.UNIQUESORT | Array.CASEINSENSITIVE);a = new Array ([1,2,3], [1,2,3,4], [], [1,2], [1]);sortall (a, compare_array_length, 0, 0);mytrace ("## Fake Array (Object with Array's methods)");fake = new Object();fake.join = Array.prototype.join;fake.toString = Array.prototype.toString;fake.push = Array.prototype.push;fake.pop = Array.prototype.pop;fake.shift = Array.prototype.shift;fake.unshift = Array.prototype.unshift;fake.reverse = Array.prototype.reverse;fake.concat = Array.prototype.concat;fake.slice = Array.prototype.slice;fake.splice = Array.prototype.splice;fake.sort = Array.prototype.sort;trace (fake.push);trace (fake.push ("a", "b", "c", "x", "z"));trace (fake.length + ": " + fake.join (":"));trace (fake.pop ());trace (fake.length + ": " + fake.join (":"));trace (fake.unshift ("y"));trace (fake.length + ": " + fake.join (":"));trace (fake.unshift ("z"));trace (fake.length + ": " + fake.join (":"));fake.length++;trace (fake.length + ": " + fake.join (":"));trace (fake.shift ());trace (fake.length + ": " + fake.join (":"));trace (fake.reverse ());trace (fake.length + ": " + fake.join (":"));trace (fake.concat ("a", fake).join (":"));trace (fake.length + ": " + fake.join (":"));trace (fake.slice (1, 3));trace (fake.length + ": " + fake.join (":"));trace (fake.splice (2, 3, "i", "j"));trace (fake.length + ": " + fake.join (":"));trace (fake.sort ());trace (fake.length + ": " + fake.join (":"));mytrace ("## Done");loadMovie ("FSCommand:quit", "");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -