UNPKG

@awayjs/graphics

Version:
933 lines (848 loc) 102 kB
export function assert(condition: any, message: any = 'assertion failed') { if (condition === '') { // avoid inadvertent false positive condition = true; } if (!condition) { if (typeof console !== 'undefined' && 'assert' in console) { console.assert(false, message); throw new Error(message); } else { //Debug.error(message.toString()); throw new Error(message); } } } export interface IDataDecoder { onData: (data: Uint8Array) => void; onError: (e) => void; push(data: Uint8Array); close(); } export interface TypedArray { buffer: ArrayBuffer; length: number; set: (array: TypedArray, offset?: number) => void; subarray: (begin: number, end?: number) => TypedArray; } //export function memCopy<T extends TypedArray>(destination: T, source: T, doffset: number = 0, export function memCopy(destination: any, source: any, doffset: number = 0, soffset: number = 0, length: number = 0) { if (soffset > 0 || (length > 0 && length < source.length)) { if (length <= 0) { length = source.length - soffset; } destination.set(source.subarray(soffset, soffset + length), doffset); } else { destination.set(source, doffset); } } /** * Faster release version of bounds. */ export class Bounds { xMin: number; yMin: number; xMax: number; yMax: number; constructor(xMin: number, yMin: number, xMax: number, yMax: number) { this.xMin = xMin | 0; this.yMin = yMin | 0; this.xMax = xMax | 0; this.yMax = yMax | 0; } //static FromUntyped(source:UntypedBounds):Bounds { static FromUntyped(source: any): Bounds { return new Bounds(source.xMin, source.yMin, source.xMax, source.yMax); } //static FromRectangle(source:ASRectangle):Bounds { static FromRectangle(source: any): Bounds { return new Bounds(source.x * 20 | 0, source.y * 20 | 0, (source.x + source.width) * 20 | 0, (source.y + source.height) * 20 | 0); } setElements(xMin: number, yMin: number, xMax: number, yMax: number): void { this.xMin = xMin; this.yMin = yMin; this.xMax = xMax; this.yMax = yMax; } copyFrom(source: Bounds): void { this.setElements(source.xMin, source.yMin, source.xMax, source.yMax); } contains(x: number, y: number): boolean { return x < this.xMin !== x < this.xMax && y < this.yMin !== y < this.yMax; } unionInPlace(other: Bounds): void { if (other.isEmpty()) { return; } this.extendByPoint(other.xMin, other.yMin); this.extendByPoint(other.xMax, other.yMax); } extendByPoint(x: number, y: number): void { this.extendByX(x); this.extendByY(y); } extendByX(x: number): void { // Exclude default values. if (this.xMin === 0x8000000) { this.xMin = this.xMax = x; return; } this.xMin = Math.min(this.xMin, x); this.xMax = Math.max(this.xMax, x); } extendByY(y: number): void { // Exclude default values. if (this.yMin === 0x8000000) { this.yMin = this.yMax = y; return; } this.yMin = Math.min(this.yMin, y); this.yMax = Math.max(this.yMax, y); } public intersects(toIntersect: Bounds): boolean { return this.contains(toIntersect.xMin, toIntersect.yMin) || this.contains(toIntersect.xMax, toIntersect.yMax); } isEmpty(): boolean { return this.xMax <= this.xMin || this.yMax <= this.yMin; } get width(): number { return this.xMax - this.xMin; } set width(value: number) { this.xMax = this.xMin + value; } get height(): number { return this.yMax - this.yMin; } set height(value: number) { this.yMax = this.yMin + value; } public getBaseWidth(angle: number): number { const u = Math.abs(Math.cos(angle)); const v = Math.abs(Math.sin(angle)); return u * (this.xMax - this.xMin) + v * (this.yMax - this.yMin); } public getBaseHeight(angle: number): number { const u = Math.abs(Math.cos(angle)); const v = Math.abs(Math.sin(angle)); return v * (this.xMax - this.xMin) + u * (this.yMax - this.yMin); } setEmpty(): void { this.xMin = this.yMin = this.xMax = this.yMax = 0; } /** * Set all fields to the sentinel value 0x8000000. * * This is what Flash uses to indicate uninitialized bounds. Important for bounds calculation * in `Graphics` instances, which start out with empty bounds but must not just extend them * from an 0,0 origin. */ setToSentinels(): void { this.xMin = this.yMin = this.xMax = this.yMax = 0x8000000; } clone(): Bounds { return new Bounds(this.xMin, this.yMin, this.xMax, this.yMax); } toString(): string { return '{ ' + 'xMin: ' + this.xMin + ', ' + 'xMin: ' + this.yMin + ', ' + 'xMax: ' + this.xMax + ', ' + 'xMax: ' + this.yMax + ' }'; } } export enum ImageType { None, /** * Premultiplied ARGB (byte-order). */ PremultipliedAlphaARGB, /** * Unpremultiplied ARGB (byte-order). */ StraightAlphaARGB, /** * Unpremultiplied RGBA (byte-order), this is what putImageData expects. */ StraightAlphaRGBA, JPEG, PNG, GIF } export function clamp(value: number, min: number, max: number) { return Math.max(min, Math.min(max, value)); } export function roundToMultipleOfFour(x: number) { return (x + 3) & ~0x3; } export function isObject(value): boolean { return typeof value === 'object' || typeof value === 'function'; } export function isNullOrUndefined(value) { return value == undefined; } function utf8decode_impl(str: string): Uint8Array { const bytes = new Uint8Array(str.length * 4); let b = 0; for (let i = 0, j = str.length; i < j; i++) { let code = str.charCodeAt(i); if (code <= 0x7f) { bytes[b++] = code; continue; } if (0xD800 <= code && code <= 0xDBFF) { const codeLow = str.charCodeAt(i + 1); if (0xDC00 <= codeLow && codeLow <= 0xDFFF) { // convert only when both high and low surrogates are present code = ((code & 0x3FF) << 10) + (codeLow & 0x3FF) + 0x10000; ++i; } } if ((code & 0xFFE00000) !== 0) { bytes[b++] = 0xF8 | ((code >>> 24) & 0x03); bytes[b++] = 0x80 | ((code >>> 18) & 0x3F); bytes[b++] = 0x80 | ((code >>> 12) & 0x3F); bytes[b++] = 0x80 | ((code >>> 6) & 0x3F); bytes[b++] = 0x80 | (code & 0x3F); } else if ((code & 0xFFFF0000) !== 0) { bytes[b++] = 0xF0 | ((code >>> 18) & 0x07); bytes[b++] = 0x80 | ((code >>> 12) & 0x3F); bytes[b++] = 0x80 | ((code >>> 6) & 0x3F); bytes[b++] = 0x80 | (code & 0x3F); } else if ((code & 0xFFFFF800) !== 0) { bytes[b++] = 0xE0 | ((code >>> 12) & 0x0F); bytes[b++] = 0x80 | ((code >>> 6) & 0x3F); bytes[b++] = 0x80 | (code & 0x3F); } else { bytes[b++] = 0xC0 | ((code >>> 6) & 0x1F); bytes[b++] = 0x80 | (code & 0x3F); } } return bytes.subarray(0, b); } function utf8encode_impl(bytes: Uint8Array): string { let j = 0, str = ''; while (j < bytes.length) { const b1 = bytes[j++] & 0xFF; if (b1 <= 0x7F) { str += String.fromCharCode(b1); } else { let currentPrefix = 0xC0; let validBits = 5; do { const mask = (currentPrefix >> 1) | 0x80; if ((b1 & mask) === currentPrefix) break; currentPrefix = (currentPrefix >> 1) | 0x80; --validBits; } while (validBits >= 0); if (validBits <= 0) { // Invalid UTF8 character -- copying as is str += String.fromCharCode(b1); continue; } let code = (b1 & ((1 << validBits) - 1)); let invalid = false; for (var i = 5; i >= validBits; --i) { const bi = bytes[j++]; if ((bi & 0xC0) != 0x80) { // Invalid UTF8 character sequence invalid = true; break; } code = (code << 6) | (bi & 0x3F); } if (invalid) { // Copying invalid sequence as is for (let k = j - (7 - i); k < j; ++k) { str += String.fromCharCode(bytes[k] & 255); } continue; } if (code >= 0x10000) { str += String.fromCharCode((((code - 0x10000) >> 10) & 0x3FF) | 0xD800, (code & 0x3FF) | 0xDC00); } else { str += String.fromCharCode(code); } } } return str; } const textEncoder = self.TextEncoder ? new self.TextEncoder() : null; const textDecoder = self.TextDecoder ? new self.TextDecoder() : null; export function utf8decode(str: string): Uint8Array { if (!textEncoder) return utf8decode_impl(str); try { return textEncoder.encode(str); } catch (e) { return utf8decode_impl(str); } } export function utf8encode(buffer: Uint8Array): string { if (!textDecoder) return utf8encode_impl(buffer); try { return textDecoder.decode(buffer); } catch (e) { return utf8encode_impl(buffer); } } /** * Simple pool allocator for ArrayBuffers. This reduces memory usage in data structures * that resize buffers. */ export class ArrayBufferPool { private _list: ArrayBuffer []; private _maxSize: number; private static _enabled = true; /** * Creates a pool that manages a pool of a |maxSize| number of array buffers. */ constructor(maxSize: number = 32) { this._list = []; this._maxSize = maxSize; } /** * Creates or reuses an existing array buffer that is at least the * specified |length|. */ public acquire(length: number): ArrayBuffer { if (ArrayBufferPool._enabled) { const list = this._list; for (let i = 0; i < list.length; i++) { const buffer = list[i]; if (buffer.byteLength >= length) { list.splice(i, 1); return buffer; } } } return new ArrayBuffer(length); } /** * Releases an array buffer that is no longer needed back to the pool. */ public release(buffer: ArrayBuffer) { if (ArrayBufferPool._enabled) { const list = this._list; //release || Debug.assert(ArrayUtilities.indexOf(list, buffer) < 0); if (list.length === this._maxSize) { list.shift(); } list.push(buffer); } } /** * Resizes a Uint8Array to have the given length. */ public ensureUint8ArrayLength(array: Uint8Array, length: number): Uint8Array { if (array.length >= length) { return array; } const newLength = Math.max(array.length + length, ((array.length * 3) >> 1) + 1); const newArray = new Uint8Array(this.acquire(newLength), 0, newLength); newArray.set(array); this.release(array.buffer); return newArray; } /** * Resizes a Float64Array to have the given length. */ public ensureFloat64ArrayLength(array: Float64Array, length: number): Float64Array { if (array.length >= length) { return array; } const newLength = Math.max(array.length + length, ((array.length * 3) >> 1) + 1); const newArray = new Float64Array(this.acquire(newLength * Float64Array.BYTES_PER_ELEMENT), 0, newLength); newArray.set(array); this.release(array.buffer); return newArray; } } /** * Makes sure that a typed array has the requested capacity. If required, it creates a new * instance of the array's class with a power-of-two capacity at least as large as required. */ //export function ensureTypedArrayCapacity<T extends TypedArray>(array: T, capacity: number): T { export function ensureTypedArrayCapacity(array: any, capacity: number): any { if (array.length < capacity) { const oldArray = array; array = new (<any>array).constructor(IntegerUtilities.nearestPowerOfTwo(capacity)); array.set(oldArray, 0); } return array; } /* interface Math { imul(a: number, b: number): number; /** * Returns the number of leading zeros of a number. * @param x A numeric expression. */ /*clz32(x: number): number; }*/ export module IntegerUtilities { var sharedBuffer = new ArrayBuffer(8); export var i8 = new Int8Array(sharedBuffer); export var u8 = new Uint8Array(sharedBuffer); export var i32 = new Int32Array(sharedBuffer); export var f32 = new Float32Array(sharedBuffer); export var f64 = new Float64Array(sharedBuffer); export var nativeLittleEndian = new Int8Array(new Int32Array([1]).buffer)[0] === 1; /** * Convert a float into 32 bits. */ export function floatToInt32(v: number) { f32[0] = v; return i32[0]; } /** * Convert 32 bits into a float. */ export function int32ToFloat(i: number) { i32[0] = i; return f32[0]; } /** * Swap the bytes of a 16 bit number. */ export function swap16(i: number) { return ((i & 0xFF) << 8) | ((i >> 8) & 0xFF); } /** * Swap the bytes of a 32 bit number. */ export function swap32(i: number) { return ((i & 0xFF) << 24) | ((i & 0xFF00) << 8) | ((i >> 8) & 0xFF00) | ((i >> 24) & 0xFF); } /** * Converts a number to s8.u8 fixed point representation. */ export function toS8U8(v: number) { return ((v * 256) << 16) >> 16; } /** * Converts a number from s8.u8 fixed point representation. */ export function fromS8U8(i: number) { return i / 256; } /** * Round trips a number through s8.u8 conversion. */ export function clampS8U8(v: number) { return fromS8U8(toS8U8(v)); } /** * Converts a number to signed 16 bits. */ export function toS16(v: number) { return (v << 16) >> 16; } export function bitCount(i: number): number { i = i - ((i >> 1) & 0x55555555); i = (i & 0x33333333) + ((i >> 2) & 0x33333333); return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24; } export function ones(i: number): number { i = i - ((i >> 1) & 0x55555555); i = (i & 0x33333333) + ((i >> 2) & 0x33333333); return ((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; } export function trailingZeros(i: number): number { return IntegerUtilities.ones((i & -i) - 1); } export function getFlags(i: number, flags: string[]): string { let str = ''; for (var i = 0; i < flags.length; i++) { if (i & (1 << i)) { str += flags[i] + ' '; } } if (str.length === 0) { return ''; } return str.trim(); } export function isPowerOfTwo(x: number) { return x && ((x & (x - 1)) === 0); } export function roundToMultipleOfFour(x: number) { return (x + 3) & ~0x3; } export function nearestPowerOfTwo(x: number) { x--; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; x++; return x; } export function roundToMultipleOfPowerOfTwo(i: number, powerOfTwo: number) { const x = (1 << powerOfTwo) - 1; return (i + x) & ~x; // Round up to multiple of power of two. } export function toHEX(i: number) { var i = (i < 0 ? 0xFFFFFFFF + i + 1 : i); return '0x' + ('00000000' + i.toString(16)).substr(-8); } /** * Polyfill imul. */ /* if (!Math.imul) { Math.imul = function imul(a, b) { var ah = (a >>> 16) & 0xffff; var al = a & 0xffff; var bh = (b >>> 16) & 0xffff; var bl = b & 0xffff; // the shift by 0 fixes the sign on the high part // the final |0 converts the unsigned value into a signed value return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0); }; }*/ /** * Polyfill clz32. */ /*if (!Math.clz32) { Math.clz32 = function clz32(i: number) { i |= (i >> 1); i |= (i >> 2); i |= (i >> 4); i |= (i >> 8); i |= (i >> 16); return 32 - IntegerUtilities.ones(i); }; }*/ } export class ABCBlock { name: string; flags: number; data: Uint8Array; } export class EncryptedBlock { constructor( public data: Uint8Array, public size: ui32, public bytePos: ui32, public rawTagId: ui8 = 0 ) {} } export class ActionBlock { actionsData: Uint8Array; precedence: number; encryptedData?: EncryptedBlock; } export class InitActionBlock { spriteId: number; actionsData: Uint8Array; encryptedData?: EncryptedBlock; } export class SymbolExport { constructor(public symbolId: number, public className: string) {} } export class UnparsedTag { constructor(public tagCode: number, public byteOffset: number, public byteLength: number) {} } export class DictionaryEntry extends UnparsedTag { public id: number; constructor(id: number, tagCode: number, byteOffset: number, byteLength: number) { super(tagCode, byteOffset, byteLength); this.id = id; } } export class EagerlyParsedDictionaryEntry extends DictionaryEntry { type: string; definition: Object; ready: boolean; constructor(id: number, unparsed: UnparsedTag, type: string, definition: any) { super(id, unparsed.tagCode, unparsed.byteOffset, unparsed.byteLength); this.type = type; this.definition = definition; this.ready = false; } } /** * Similar to |toString| but returns |null| for |null| or |undefined| instead * of "null" or "undefined". */ export function axCoerceString(x): string { if (typeof x === 'string') { return x; } else if (x == undefined) { return null; } return x + ''; } export var Errors = { /** * AVM2 Error Codes */ // OutOfMemoryError : {code: 1000, message: "The system is out of memory."}, NotImplementedError : { code: 1001, message: 'The method %1 is not implemented.' }, InvalidPrecisionError : { code: 1002, message: 'Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.' }, InvalidRadixError : { code: 1003, message: 'The radix argument must be between 2 and 36; got %1.' }, InvokeOnIncompatibleObjectError : { code: 1004, message: 'Method %1 was invoked on an incompatible object.' }, ArrayIndexNotIntegerError : { code: 1005, message: 'Array index is not a positive integer (%1).' }, CallOfNonFunctionError : { code: 1006, message: '%1 is not a function.' }, ConstructOfNonFunctionError : { code: 1007, message: 'Instantiation attempted on a non-constructor.' }, // AmbiguousBindingError : {code: 1008, message: "%1 is ambiguous; Found more than one matching binding."}, ConvertNullToObjectError : { code: 1009, message: 'Cannot access a property or method of a null object reference.' }, ConvertUndefinedToObjectError : { code: 1010, message: 'A term is undefined and has no properties.' }, // IllegalOpcodeError : {code: 1011, message: "Method %1 contained illegal opcode %2 at offset %3."}, // LastInstExceedsCodeSizeError : {code: 1012, message: "The last instruction exceeded code size."}, // FindVarWithNoScopeError : {code: 1013, message: "Cannot call OP_findproperty when scopeDepth is 0."}, ClassNotFoundError : { code: 1014, message: 'Class %1 could not be found.' }, // IllegalSetDxns : {code: 1015, message: "Method %1 cannot set default xml namespace"}, DescendentsError : { code: 1016, message: 'Descendants operator (..) not supported on type %1.' }, // ScopeStackOverflowError : {code: 1017, message: "Scope stack overflow occurred."}, // ScopeStackUnderflowError : {code: 1018, message: "Scope stack underflow occurred."}, // GetScopeObjectBoundsError : {code: 1019, message: "Getscopeobject %1 is out of bounds."}, // CannotFallOffMethodError : {code: 1020, message: "Code cannot fall off the end of a method."}, // InvalidBranchTargetError : {code: 1021, message: "At least one branch target was not on a valid instruction in the method."}, // IllegalVoidError : {code: 1022, message: "Type void may only be used as a function return type."}, StackOverflowError : { code: 1023, message: 'Stack overflow occurred.' }, // StackUnderflowError : {code: 1024, message: "Stack underflow occurred."}, // InvalidRegisterError : {code: 1025, message: "An invalid register %1 was accessed."}, // SlotExceedsCountError : {code: 1026, message: "Slot %1 exceeds slotCount=%2 of %3."}, // MethodInfoExceedsCountError : {code: 1027, message: "Method_info %1 exceeds method_count=%2."}, // DispIdExceedsCountError : {code: 1028, message: "Disp_id %1 exceeds max_disp_id=%2 of %3."}, // DispIdUndefinedError : {code: 1029, message: "Disp_id %1 is undefined on %2."}, // StackDepthUnbalancedError : {code: 1030, message: "Stack depth is unbalanced. %1 != %2."}, // ScopeDepthUnbalancedError : {code: 1031, message: "Scope depth is unbalanced. %1 != %2."}, CpoolIndexRangeError : { code: 1032, message: 'Cpool index %1 is out of range %2.' }, CpoolEntryWrongTypeError : { code: 1033, message: 'Cpool entry %1 is wrong type.' }, CheckTypeFailedError : { code: 1034, message: 'Type Coercion failed: cannot convert %1 to %2.' }, // IllegalSuperCallError : {code: 1035, message: "Illegal super expression found in method %1."}, CannotAssignToMethodError : { code: 1037, message: 'Cannot assign to a method %1 on %2.' }, // RedefinedError : {code: 1038, message: "%1 is already defined."}, // CannotVerifyUntilReferencedError : {code: 1039, message: "Cannot verify method until it is referenced."}, CantUseInstanceofOnNonObjectError : { code: 1040, message: 'The right-hand side of instanceof must be a class or function.' }, IsTypeMustBeClassError : { code: 1041, message: 'The right-hand side of operator must be a class.' }, InvalidMagicError : { code: 1042, message: 'Not an ABC file. major_version=%1 minor_version=%2.' }, // InvalidCodeLengthError : {code: 1043, message: "Invalid code_length=%1."}, // InvalidMethodInfoFlagsError : {code: 1044, message: "MethodInfo-%1 unsupported flags=%2."}, UnsupportedTraitsKindError : { code: 1045, message: 'Unsupported traits kind=%1.' }, // MethodInfoOrderError : {code: 1046, message: "MethodInfo-%1 referenced before definition."}, // MissingEntryPointError : {code: 1047, message: "No entry point was found."}, PrototypeTypeError : { code: 1049, message: 'Prototype objects must be vanilla Objects.' }, ConvertToPrimitiveError : { code: 1050, message: 'Cannot convert %1 to primitive.' }, // IllegalEarlyBindingError : {code: 1051, message: "Illegal early binding access to %1."}, InvalidURIError : { code: 1052, message: 'Invalid URI passed to %1 function.' }, // IllegalOverrideError : {code: 1053, message: "Illegal override of %1 in %2."}, // IllegalExceptionHandlerError : {code: 1054, message: "Illegal range or target offsets in exception handler."}, WriteSealedError : { code: 1056, message: 'Cannot create property %1 on %2.' }, // IllegalSlotError : {code: 1057, message: "%1 can only contain methods."}, // IllegalOperandTypeError : {code: 1058, message: "Illegal operand type: %1 must be %2."}, // ClassInfoOrderError : {code: 1059, message: "ClassInfo-%1 is referenced before definition."}, // ClassInfoExceedsCountError : {code: 1060, message: "ClassInfo %1 exceeds class_count=%2."}, // NumberOutOfRangeError : {code: 1061, message: "The value %1 cannot be converted to %2 without losing precision."}, WrongArgumentCountError : { code: 1063, message: 'Argument count mismatch on %1. Expected %2, got %3.' }, // CannotCallMethodAsConstructor : {code: 1064, message: "Cannot call method %1 as constructor."}, UndefinedVarError : { code: 1065, message: 'Variable %1 is not defined.' }, // FunctionConstructorError : {code: 1066, message: "The form function('function body') is not supported."}, // IllegalNativeMethodBodyError : {code: 1067, message: "Native method %1 has illegal method body."}, // CannotMergeTypesError : {code: 1068, message: "%1 and %2 cannot be reconciled."}, ReadSealedError : { code: 1069, message: 'Property %1 not found on %2 and there is no default value.' }, // CallNotFoundError : {code: 1070, message: "Method %1 not found on %2"}, // AlreadyBoundError : {code: 1071, message: "Function %1 has already been bound to %2."}, // ZeroDispIdError : {code: 1072, message: "Disp_id 0 is illegal."}, // DuplicateDispIdError : {code: 1073, message: "Non-override method %1 replaced because of duplicate disp_id %2."}, ConstWriteError : { code: 1074, message: 'Illegal write to read-only property %1 on %2.' }, // MathNotFunctionError : {code: 1075, message: "Math is not a function."}, // MathNotConstructorError : {code: 1076, message: "Math is not a constructor."}, // WriteOnlyError : {code: 1077, message: "Illegal read of write-only property %1 on %2."}, // IllegalOpMultinameError : {code: 1078, message: "Illegal opcode/multiname combination: %1<%2>."}, // IllegalNativeMethodError : {code: 1079, message: "Native methods are not allowed in loaded code."}, // IllegalNamespaceError : {code: 1080, message: "Illegal value for namespace."}, // ReadSealedErrorNs : {code: 1081, message: "Property %1 not found on %2 and there is no default value."}, // NoDefaultNamespaceError : {code: 1082, message: "No default namespace has been set."}, XMLPrefixNotBound : { code: 1083, message: 'The prefix "%1" for element "%2" is not bound.' }, // XMLBadQName : {code: 1084, message: "Element or attribute (\"%1\") does not match QName production: QName::=(NCName':')?NCName."}, XMLUnterminatedElementTag : { code: 1085, message: 'The element type "%1" must be terminated by the matching end-tag "</%2>".' }, XMLOnlyWorksWithOneItemLists : { code: 1086, message: 'The %1 method only works on lists containing one item.' }, XMLAssignmentToIndexedXMLNotAllowed : { code: 1087, message: 'Assignment to indexed XML is not allowed.' }, XMLMarkupMustBeWellFormed : { code: 1088, message: 'The markup in the document following the root element must be well-formed.' }, XMLAssigmentOneItemLists : { code: 1089, message: 'Assignment to lists with more than one item is not supported.' }, XMLMalformedElement : { code: 1090, message: 'XML parser failure: element is malformed.' }, XMLUnterminatedCData : { code: 1091, message: 'XML parser failure: Unterminated CDATA section.' }, XMLUnterminatedXMLDecl : { code: 1092, message: 'XML parser failure: Unterminated XML declaration.' }, XMLUnterminatedDocTypeDecl : { code: 1093, message: 'XML parser failure: Unterminated DOCTYPE declaration.' }, XMLUnterminatedComment : { code: 1094, message: 'XML parser failure: Unterminated comment.' }, // XMLUnterminatedAttribute : {code: 1095, message: "XML parser failure: Unterminated attribute."}, XMLUnterminatedElement : { code: 1096, message: 'XML parser failure: Unterminated element.' }, // XMLUnterminatedProcessingInstruction : {code: 1097, message: "XML parser failure: Unterminated processing instruction."}, XMLNamespaceWithPrefixAndNoURI : { code: 1098, message: 'Illegal prefix %1 for no namespace.' }, RegExpFlagsArgumentError : { code: 1100, message: 'Cannot supply flags when constructing one RegExp from another.' }, // NoScopeError : {code: 1101, message: "Cannot verify method %1 with unknown scope."}, // IllegalDefaultValue : {code: 1102, message: "Illegal default value for type %1."}, // CannotExtendFinalClass : {code: 1103, message: "Class %1 cannot extend final base class."}, // XMLDuplicateAttribute : {code: 1104, message: "Attribute \"%1\" was already specified for element \"%2\"."}, // CorruptABCError : {code: 1107, message: "The ABC data is corrupt, attempt to read out of bounds."}, InvalidBaseClassError : { code: 1108, message: 'The OP_newclass opcode was used with the incorrect base class.' }, // DanglingFunctionError : {code: 1109, message: "Attempt to directly call unbound function %1 from method %2."}, // CannotExtendError : {code: 1110, message: "%1 cannot extend %2."}, // CannotImplementError : {code: 1111, message: "%1 cannot implement %2."}, // CoerceArgumentCountError : {code: 1112, message: "Argument count mismatch on class coercion. Expected 1, got %1."}, // InvalidNewActivationError : {code: 1113, message: "OP_newactivation used in method without NEED_ACTIVATION flag."}, // NoGlobalScopeError : {code: 1114, message: "OP_getglobalslot or OP_setglobalslot used with no global scope."}, // NotConstructorError : {code: 1115, message: "%1 is not a constructor."}, // ApplyError : {code: 1116, message: "second argument to Function.prototype.apply must be an array."}, XMLInvalidName : { code: 1117, message: 'Invalid XML name: %1.' }, XMLIllegalCyclicalLoop : { code: 1118, message: 'Illegal cyclical loop between nodes.' }, // DeleteTypeError : {code: 1119, message: "Delete operator is not supported with operand of type %1."}, // DeleteSealedError : {code: 1120, message: "Cannot delete property %1 on %2."}, // DuplicateMethodBodyError : {code: 1121, message: "Method %1 has a duplicate method body."}, // IllegalInterfaceMethodBodyError : {code: 1122, message: "Interface method %1 has illegal method body."}, FilterError : { code: 1123, message: 'Filter operator not supported on type %1.' }, // InvalidHasNextError : {code: 1124, message: "OP_hasnext2 requires object and index to be distinct registers."}, OutOfRangeError : { code: 1125, message: 'The index %1 is out of range %2.' }, VectorFixedError : { code: 1126, message: 'Cannot change the length of a fixed Vector.' }, TypeAppOfNonParamType : { code: 1127, message: 'Type application attempted on a non-parameterized type.' }, WrongTypeArgCountError : { code: 1128, message: 'Incorrect number of type parameters for %1. Expected %2, got %3.' }, JSONCyclicStructure : { code: 1129, message: 'Cyclic structure cannot be converted to JSON string.' }, JSONInvalidReplacer : { code: 1131, message: 'Replacer argument to JSON stringifier must be an array or a two parameter function.' }, JSONInvalidParseInput : { code: 1132, message: 'Invalid JSON parse input.' }, // FileOpenError : {code: 1500, message: "Error occurred opening file %1."}, // FileWriteError : {code: 1501, message: "Error occurred writing to file %1."}, // ScriptTimeoutError : {code: 1502, message: "A script has executed for longer than the default timeout period of 15 seconds."}, // ScriptTerminatedError : {code: 1503, message: "A script failed to exit after 30 seconds and was terminated."}, // EndOfFileError : {code: 1504, message: "End of file."}, // StringIndexOutOfBoundsError : {code: 1505, message: "The string index %1 is out of bounds; must be in range %2 to %3."}, InvalidRangeError : { code: 1506, message: 'The specified range is invalid.' }, NullArgumentError : { code: 1507, message: 'Argument %1 cannot be null.' }, InvalidArgumentError : { code: 1508, message: 'The value specified for argument %1 is invalid.' }, ArrayFilterNonNullObjectError : { code: 1510, message: 'When the callback argument is a method of a class, the optional this argument must be null.' }, InvalidParamError : { code: 2004, message: 'One of the parameters is invalid.' }, ParamRangeError : { code: 2006, message: 'The supplied index is out of bounds.' }, NullPointerError : { code: 2007, message: 'Parameter %1 must be non-null.' }, InvalidEnumError : { code: 2008, message: 'Parameter %1 must be one of the accepted values.' }, CantInstantiateError : { code: 2012, message: '%1 class cannot be instantiated.' }, InvalidBitmapData : { code: 2015, message: 'Invalid BitmapData.' }, EOFError : { code: 2030, message: 'End of file was encountered.', fqn: 'flash.errors.EOFError' }, CompressedDataError : { code: 2058, message: 'There was an error decompressing the data.', fqn: 'flash.errors.IOError' }, EmptyStringError : { code: 2085, message: 'Parameter %1 must be non-empty string.' }, ProxyGetPropertyError : { code: 2088, message: 'The Proxy class does not implement getProperty. It must be overridden by a subclass.' }, ProxySetPropertyError : { code: 2089, message: 'The Proxy class does not implement setProperty. It must be overridden by a subclass.' }, ProxyCallPropertyError : { code: 2090, message: 'The Proxy class does not implement callProperty. It must be overridden by a subclass.' }, ProxyHasPropertyError : { code: 2091, message: 'The Proxy class does not implement hasProperty. It must be overridden by a subclass.' }, ProxyDeletePropertyError : { code: 2092, message: 'The Proxy class does not implement deleteProperty. It must be overridden by a subclass.' }, ProxyGetDescendantsError : { code: 2093, message: 'The Proxy class does not implement getDescendants. It must be overridden by a subclass.' }, ProxyNextNameIndexError : { code: 2105, message: 'The Proxy class does not implement nextNameIndex. It must be overridden by a subclass.' }, ProxyNextNameError : { code: 2106, message: 'The Proxy class does not implement nextName. It must be overridden by a subclass.' }, ProxyNextValueError : { code: 2107, message: 'The Proxy class does not implement nextValue. It must be overridden by a subclass.' }, // InvalidArrayLengthError : {code: 2108, message: "The value %1 is not a valid Array length."}, // ReadExternalNotImplementedError : {code: 2173, message: "Unable to read object in stream. The class %1 does not implement flash.utils.IExternalizable but is aliased to an externalizable class."}, /** * Player Error Codes */ // NoSecurityContextError : { code: 2000, message: "No active security context."}, TooFewArgumentsError : { code: 2001, message: 'Too few arguments were specified; got %1, %2 expected.' }, // InvalidSocketError : { code: 2002, message: "Operation attempted on invalid socket."}, // InvalidSocketPortError : { code: 2003, message: "Invalid socket port number specified."}, ParamTypeError : { code: 2005, message: 'Parameter %1 is of the incorrect type. Should be type %2.' }, // HasStyleSheetError : { code: 2009, message: "This method cannot be used on a text field with a style sheet."}, // SocketLocalFileSecurityError : { code: 2010, message: "Local-with-filesystem SWF files are not permitted to use sockets."}, SocketConnectError : { code: 2011, message: 'Socket connection failed to %1:%2.' }, // AuthoringOnlyFeatureError : { code: 2013, message: "Feature can only be used in Flash Authoring."}, // FeatureNotAvailableError : { code: 2014, message: "Feature is not available at this time."}, // InvalidBitmapDataError : { code: 2015, message: "Invalid BitmapData."}, // SystemExitSecurityError : { code: 2017, message: "Only trusted local files may cause the Flash Player to exit."}, // SystemExitUnsupportedError : { code: 2018, message: "System.exit is only available in the standalone Flash Player."}, // InvalidDepthError : { code: 2019, message: "Depth specified is invalid."}, // MovieClipSwapError : { code: 2020, message: "MovieClips objects with different parents cannot be swapped."}, // ObjectCreationError : { code: 2021, message: "Object creation failed."}, // NotDisplayObjectError : { code: 2022, message: "Class %1 must inherit from DisplayObject to link to a symbol."}, // NotSpriteError : { code: 2023, message: "Class %1 must inherit from Sprite to link to the root."}, CantAddSelfError : { code: 2024, message: 'An object cannot be added as a child of itself.' }, NotAChildError : { code: 2025, message: 'The supplied DisplayObject must be a child of the caller.' }, // NavigateURLError : { code: 2026, message: "An error occurred navigating to the URL %1."}, // MustBeNonNegativeError : { code: 2027, message: "Parameter %1 must be a non-negative number; got %2."}, // LocalSecurityError : { code: 2028, message: "Local-with-filesystem SWF file %1 cannot access Internet URL %2."}, // InvalidStreamError : { code: 2029, message: "This URLStream object does not have a stream opened."}, // SocketError : { code: 2031, message: "Socket Error."}, // StreamError : { code: 2032, message: "Stream Error."}, // KeyGenerationError : { code: 2033, message: "Key Generation Failed."}, // InvalidKeyError : { code: 2034, message: "An invalid digest was supplied."}, // URLNotFoundError : { code: 2035, message: "URL Not Found."}, // LoadNeverCompletedError : { code: 2036, message: "Load Never Completed."}, // InvalidCallError : { code: 2037, message: "Functions called in incorrect sequence, or earlier call was unsuccessful."}, // FileIOError : { code: 2038, message: "File I/O Error."}, // RemoteURLError : { code: 2039, message: "Invalid remote URL protocol. The remote URL protocol must be HTTP or HTTPS."}, // BrowseInProgressError : { code: 2041, message: "Only one file browsing session may be performed at a time."}, // DigestNotSupportedError : { code: 2042, message: "The digest property is not supported by this load operation."}, UnhandledError : { code: 2044, message: 'Unhandled %1:.' }, // FileVerificationError : { code: 2046, message: "The loaded file did not have a valid signature."}, // DisplayListSecurityError : { code: 2047, message: "Security sandbox violation: %1: %2 cannot access %3."}, // DownloadSecurityError : { code: 2048, message: "Security sandbox violation: %1 cannot load data from %2."}, // UploadSecurityError : { code: 2049, message: "Security sandbox violation: %1 cannot upload data to %2."}, // OutboundScriptingSecurityError : { code: 2051, message: "Security sandbox violation: %1 cannot evaluate scripting URLs within %2 (allowScriptAccess is %3). Attempted URL was %4."}, AllowDomainArgumentError : { code: 2052, message: 'Only String arguments are permitted for allowDomain and allowInsecureDomain.' }, // IntervalSecurityError : { code: 2053, message: "Security sandbox violation: %1 cannot clear an interval timer set by %2."}, // ExactSettingsError : { code: 2054, message: "The value of Security.exactSettings cannot be changed after it has been used."}, // PrintJobStartError : { code: 2055, message: "The print job could not be started."}, // PrintJobSendError : { code: 2056, message: "The print job could not be sent to the printer."}, // PrintJobAddPageError : { code: 2057, message: "The page could not be added to the print job."}, // ExternalCallbackSecurityError : { code: 2059, message: "Security sandbox violation: %1 cannot overwrite an ExternalInterface callback added by %2."}, // ExternalInterfaceSecurityError : { code: 2060, message: "Security sandbox violation: ExternalInterface caller %1 cannot access %2."}, // ExternalInterfaceNoCallbackError : { code: 2061, message: "No ExternalInterface callback %1 registered."}, // NoCloneMethodError : { code: 2062, message: "Children of Event must override clone() {return new MyEventClass (...);}."}, // IMEError : { code: 2063, message: "Error attempting to execute IME command."}, // FocusNotSetError : { code: 2065, message: "The focus cannot be set for this target."}, DelayRangeError : { code: 2066, message: 'The Timer delay specified is out of range.' }, ExternalInterfaceNotAvailableError : { code: 2067, message: 'The ExternalInterface is not available in this container. ExternalInterface requires Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime.' }, // InvalidSoundError : { code: 2068, message: "Invalid sound."}, InvalidLoaderMethodError : { code: 2069, message: 'The Loader class does not implement this method.' }, // StageOwnerSecurityError : { code: 2070, message: "Security sandbox violation: caller %1 cannot access Stage owned by %2."}, InvalidStageMethodError : { code: 2071, message: 'The Stage class does not implement this property or method.' }, // ProductManagerDiskError : { code: 2073, message: "There was a problem saving the application to disk."}, // ProductManagerStageError : { code: 2074, message: "The stage is too small to fit the download ui."}, // ProductManagerVerifyError : { code: 2075, message: "The downloaded file is invalid."}, // FilterFailedError : { code: 2077, message: "This filter operation cannot be performed with the specified input parameters."}, TimelineObjectNameSealedError : { code: 2078, message: 'The name property of a Timeline-placed object cannot be modified.' }, // BitmapNotAssociatedWithBitsCharError : { code: 2079, message: "Classes derived from Bitmap can only be associated with defineBits characters (bitmaps)."}, AlreadyConnectedError : { code: 2082, message: 'Connect failed because the object is already connected.' }, CloseNotConnectedError : { code: 2083, message: 'Close failed because the object is not connected.' }, ArgumentSizeError : { code: 2084, message: 'The AMF encoding of the arguments cannot exceed 40K.' }, // FileReferenceProhibitedError : { code: 2086, message: "A setting in the mms.cfg file prohibits this FileReference request."}, // DownloadFileNameProhibitedError : { code: 2087, message: "The FileReference.download() file name contains prohibited characters."}, // EventDispatchRecursionError : { code: 2094, message: "Event dispatch recursion overflow."}, AsyncError : { code: 2095, message: '%1 was unable to invoke callback %2.' }, // DisallowedHTTPHeaderError : { code: 2096, message: "The HTTP request header %1 cannot be set via ActionScript."}, // FileFilterError : { code: 2097, message: "The FileFilter Array is not in the correct format."}, LoadingObjectNotSWFError : { code: 2098, message: 'The loading object is not a .swf file, you cannot request SWF properties from it.' }, LoadingObjectNotInitializedError : { code: 2099, message: 'The loading object is not sufficiently loaded to provide this information.' }, // EmptyByteArrayError : { code: 2100, message: "The ByteArray parameter in Loader.loadBytes() must have length greater than 0."}, DecodeParamError : { code: 2101, message: 'The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.' }, // NotAnXMLChildError : { code: 2102, message: "The before XMLNode parameter must be a child of the caller."}, // XMLRecursionError : { code: 2103, message: "XML recursion failure: new child would create infinite loop."}, SceneNotFoundError : { code: 2108, message: 'Scene %1 was not found.' }, FrameLabelNotFoundError : { code: 2109, message: 'Frame label %1 not found in scene %2.' }, // DisableAVM1LoadingError : { code: 2110, message: "The value of Security.disableAVM1Loading cannot be set unless the caller can access the stage and is in an ActionScript 3.0 SWF file."}, // AVM1LoadingError : { code: 2111, message: "Security.disableAVM1Loading is true so the current load of the ActionScript 1.0/2.0 SWF file has been blocked."}, // ApplicationDomainSecurityError : { code: 2112, message: "Provided parameter LoaderContext.ApplicationDomain is from a disallowed domain."}, // SecurityDomainSecurityError : { code: 2113, message: "Provided parameter LoaderContext.SecurityDomain is from a disallowed domain."}, // NonNullPointerError : { code: 2114, message: "Parameter %1 must be null."}, // TrueParamError : { code: 2115, message: "Parameter %1 must be false."}, // FalseParamError : { code: 2116, message: "Parameter %1 must be true."}, InvalidLoaderInfoMethodError : { code: 2118, message: 'The LoaderInfo class does not implement this method.' }, // LoaderInfoAppDomainSecurityError : { code: 2119, message: "Security sandbox violation: caller %1 cannot access LoaderInfo.applicationDomain owned by %2."}, SecuritySwfNotAllowedError : { code: 2121, message: 'Security sandbox violation: %1: %2 cannot access %3. This may be worked around by calling Security.allowDomain.' }, // SecurityNonSwfIncompletePolicyFilesError : { code: 2122, message: "Security sandbox violation: %1: %2 cannot access %3. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded."}, // SecurityNonSwfNotAllowedError : { code: 2123, message: "Security sandbox violation: %1: %2 cannot access %3. No policy files granted access."}, UnknownFileTypeError : { code: 2124, message: 'Loaded file is an unknown type.' }, // SecurityCrossVMNotAllowedError : { code: 2125, message: "Security sandbox violation: %1 cannot use Runtime Shared Library %2 because crossing the boundary between ActionScript 3.0 and ActionScript 1.0/2.0 objects is not allowed."}, // NotConnectedError : { code: 2126, message: "NetConnection object must be connected."}, // FileRefBadPostDataTypeError : { code: 2127, message: "FileReference POST data cannot be type ByteArray."}, // NetConnectionConnectError : { code: 2129, message: "Connection to %1 failed."}, // SharedObjectFlushFailedError : { code: 2130, message: "Unable to flush SharedObject."}, // DefinitionNotFoundError : { code: 2131, message: "Definition %1 cannot be found."}, // NetConnectionInvalidConnectFromNetStatusEventError : { code: 2132, message: "NetConnection.connect cannot be called from a netStatus event handler."}, // CallbackNotRegisteredError : { code: 2133, message: "Callback %1 is not registered."}, // SharedObjectCreateError : { code: 2134, message: "Cannot create SharedObject."}, // InvalidSWFError : { co