import os
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Optional, Union
from typing_extensions import Final

if TYPE_CHECKING:
    # Circular import otherwise
    from ..decompile import ByteCodeDecompiler


class Expression:
    # Any thing that can be evaluated for a result, such as a variable
    # reference, function call, or mathematical operation.
    def render(self, parent_prefix: str, nested: bool = False) -> str:
        raise NotImplementedError(f"{self.__class__.__name__} does not implement render()!")


class GenericObject(Expression):
    # One of several built-in object types that can be found in AFP bytecode.
    # The possible values are all instantiated below and we perform 'is' checks
    # to determine what actual object is being accessed.
    def __init__(self, name: str) -> None:
        self.name = name

    def __repr__(self) -> str:
        return self.name

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        return self.name


NULL = GenericObject("NULL")
UNDEFINED = GenericObject("UNDEFINED")
THIS = GenericObject("THIS")
ROOT = GenericObject("ROOT")
PARENT = GenericObject("PARENT")
CLIP = GenericObject("CLIP")
GLOBAL = GenericObject("GLOBAL")


class Register(Expression):
    def __init__(self, no: int) -> None:
        self.no = no

    def __repr__(self) -> str:
        return f"Register({self.no})"

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        return f"registers[{self.no}]"


class StringConstant(Expression):
    __PROPERTIES: Final[List[Tuple[int, str]]] = [
        # Seems to be properties on every object. These also match the original
        # SWF properties up to 0x115. GET_PROPERTY and SET_PROPERTY use these
        # values to determine what to look up on an object.
        (0x100, "_x"),
        (0x101, "_y"),
        (0x102, "_xscale"),
        (0x103, "_yscale"),
        (0x104, "_currentframe"),
        (0x105, "_totalframes"),
        (0x106, "_alpha"),
        (0x107, "_visible"),
        (0x108, "_width"),
        (0x109, "_height"),
        (0x10A, "_rotation"),
        (0x10B, "_target"),
        (0x10C, "_framesloaded"),
        (0x10D, "_name"),
        (0x10E, "_droptarget"),
        (0x10F, "_url"),
        (0x110, "_highquality"),
        (0x111, "_focusrect"),
        (0x112, "_soundbuftime"),
        (0x113, "_quality"),
        (0x114, "_xmouse"),
        (0x115, "_ymouse"),
        (0x116, "_z"),
        # Global properties on every object.
        (0x120, "this"),
        (0x121, "_root"),
        (0x122, "_parent"),
        (0x123, "_global"),
        (0x124, "arguments"),
        # Object properties?
        (0x140, "blendMode"),
        (0x141, "enabled"),
        (0x142, "hitArea"),
        (0x143, "_lockroot"),
        (0x144, "$version"),
        (0x145, "numChildren"),
        (0x146, "transform"),
        (0x147, "graphics"),
        (0x148, "loaderInfo"),
        (0x149, "mask"),
        (0x14A, "upState"),
        (0x14B, "overState"),
        (0x14C, "downState"),
        (0x14D, "hitTestState"),
        (0x14E, "doubleClickEnabled"),
        (0x14F, "cacheAsBitmap"),
        (0x150, "scrollRect"),
        (0x151, "opaqueBackground"),
        (0x152, "tabChildren"),
        (0x153, "tabEnabled"),
        (0x154, "tabIndex"),
        (0x155, "mouseEnabled"),
        (0x156, "mouseChildren"),
        (0x157, "buttonMode"),
        (0x158, "useHandCursor"),
        # Text input properties.
        (0x160, "textWidth"),
        (0x161, "textHeight"),
        (0x162, "text"),
        (0x163, "autoSize"),
        (0x164, "textColor"),
        (0x165, "selectable"),
        (0x166, "multiline"),
        (0x167, "wordWrap"),
        (0x168, "border"),
        (0x169, "borderColor"),
        (0x16A, "background"),
        (0x16B, "backgroundColor"),
        (0x16C, "embedFonts"),
        (0x16D, "defaultTextFormat"),
        (0x16E, "htmlText"),
        (0x16F, "mouseWheelEnabled"),
        (0x170, "maxChars"),
        (0x171, "sharpness"),
        (0x172, "thickness"),
        (0x173, "antiAliasType"),
        (0x174, "gridFitType"),
        (0x175, "maxScrollH"),
        (0x176, "maxScrollV"),
        (0x177, "restrict"),
        (0x178, "numLines"),
        # Color properties?
        (0x180, "ra"),
        (0x181, "rb"),
        (0x182, "ga"),
        (0x183, "gb"),
        (0x184, "ba"),
        (0x185, "bb"),
        (0x186, "aa"),
        (0x187, "ab"),
        # Text properties?
        (0x1A0, "font"),
        (0x1A1, "size"),
        (0x1A2, "color"),
        (0x1A3, "bold"),
        (0x1A4, "italic"),
        (0x1A5, "underline"),
        (0x1A6, "url"),
        (0x1A7, "target"),
        (0x1A8, "align"),
        (0x1A9, "leftMargin"),
        (0x1AA, "rightMargin"),
        (0x1AB, "indent"),
        (0x1AC, "leading"),
        (0x1AD, "letterSpacing"),
        # Who the fuck knows...
        (0x1C0, "a"),
        (0x1C1, "b"),
        (0x1C2, "c"),
        (0x1C3, "d"),
        (0x1C4, "e"),
        (0x1C5, "f"),
        (0x1C6, "g"),
        (0x1C7, "h"),
        (0x1C8, "i"),
        (0x1C9, "j"),
        (0x1CA, "k"),
        (0x1CB, "l"),
        (0x1CC, "m"),
        (0x1CD, "n"),
        (0x1CE, "o"),
        (0x1CF, "p"),
        (0x1D0, "q"),
        (0x1D1, "r"),
        (0x1D2, "s"),
        (0x1D3, "t"),
        (0x1D4, "u"),
        (0x1D5, "v"),
        (0x1D6, "w"),
        (0x1D7, "x"),
        (0x1D8, "y"),
        (0x1D9, "z"),
        (0x1DA, "tx"),
        (0x1DB, "ty"),
        (0x1DC, "length"),
        (0x1DD, "ignoreWhite"),
        (0x1DE, "loaded"),
        (0x1DF, "childNodes"),
        (0x1E0, "firstChild"),
        (0x1E1, "nodeValue"),
        (0x1E2, "nextSibling"),
        (0x1E3, "nodeName"),
        (0x1E4, "nodeType"),
        (0x1E5, "attributes"),
        (0x1E6, "__count"),
        (0x1E7, "__type"),
        (0x1E8, "width"),
        (0x1E9, "height"),
        (0x1EA, "useCodepage"),
        (0x1EB, "duration"),
        (0x1EC, "position"),
        (0x1ED, "matrixType"),
        (0x1EE, "matrix"),
        (0x1EF, "prototype"),
        (0x1F0, "__proto__"),
        (0x1F1, "xMin"),
        (0x1F2, "xMax"),
        (0x1F3, "yMin"),
        (0x1F4, "yMax"),
        (0x1F5, "lastChild"),
        (0x1F6, "parentNode"),
        (0x1F7, "previousSibling"),
        (0x1F8, "callee"),
        (0x1F9, "caller"),
        (0x1FA, "colorTransform"),
        (0x1FB, "concatenatedColorTransform"),
        (0x1FC, "concatenatedMatrix"),
        (0x1FD, "pixelBounds"),
        (0x1FE, "matrix3D"),
        (0x1FF, "perspectiveProjection"),
        # Commands and object references?
        (0x200, "FSCommand:fullscreen"),
        (0x201, "FSCommand:showmenu"),
        (0x202, "FSCommand:allowscale"),
        (0x203, "FSCommand:quit"),
        (0x204, "NaN"),
        (0x205, "Infinity"),
        (0x206, "number"),
        (0x207, "boolean"),
        (0x208, "string"),
        (0x209, "object"),
        (0x20A, "movieclip"),
        (0x20B, "null"),
        (0x20C, "undefined"),
        (0x20D, "function"),
        (0x20E, "normal"),
        (0x20F, "layer"),
        (0x210, "darken"),
        (0x211, "multiply"),
        (0x212, "lighten"),
        (0x213, "screen"),
        (0x214, "overlay"),
        (0x215, "hardlight"),
        (0x216, "subtract"),
        (0x217, "difference"),
        (0x218, "invert"),
        (0x219, "alpha"),
        (0x21A, "erase"),
        (0x21B, "/"),
        (0x21C, ".."),
        (0x21D, "linear"),
        (0x21E, "radial"),
        (0x21F, "none"),
        (0x220, "square"),
        (0x221, "miter"),
        (0x222, "bevel"),
        (0x223, "left"),
        (0x224, "right"),
        (0x225, "center"),
        (0x226, "box"),
        (0x227, "reflect"),
        (0x228, "repeat"),
        (0x229, "RGB"),
        (0x22A, "linearRGB"),
        (0x22B, "justify"),
        (0x22C, "shader"),
        (0x22D, "vertical"),
        (0x22E, "horizontal"),
        (0x22F, "pad"),
        (0x230, "evenOdd"),
        (0x231, "nonZero"),
        (0x232, "negative"),
        (0x233, "positive"),
        (0x234, "xml"),
        (0x235, "B"),
        (0x236, "BL"),
        (0x237, "BR"),
        (0x238, "L"),
        (0x239, "R"),
        (0x23A, "T"),
        (0x23B, "TL"),
        (0x23C, "TR"),
        (0x23D, "exactFit"),
        (0x23E, "noBorder"),
        (0x23F, "noScale"),
        (0x240, "showAll"),
        (0x241, "easeInSine"),
        (0x242, "easeOutSine"),
        (0x243, "easeInOutSine"),
        (0x244, "easeOutInSine"),
        (0x245, "easeInQuad"),
        (0x246, "easeOutQuad"),
        (0x247, "easeInOutQuad"),
        (0x248, "easeOutInQuad"),
        (0x249, "easeInFlash"),
        (0x24A, "easeOutFlash"),
        (0x24B, "element"),
        (0x24C, "dynamic"),
        (0x24D, "binary"),
        (0x24E, "variables"),
        (0x24F, "LB"),
        (0x250, "RB"),
        (0x251, "LT"),
        (0x252, "RT"),
        (0x253, ""),
        (0x254, "arrow"),
        (0x255, "auto"),
        (0x256, "button"),
        (0x257, "hand"),
        (0x258, "ibeam"),
        (0x259, "advanced"),
        (0x25A, "pixel"),
        (0x25B, "subpixel"),
        (0x25C, "full"),
        (0x25D, "inner"),
        (0x25E, "outer"),
        (0x25F, "easeInBack"),
        (0x260, "easeOutBack"),
        (0x261, "easeInOutBack"),
        (0x262, "easeOutInBack"),
        (0x263, "registerClassConstructor"),
        (0x264, "setter"),
        (0x265, "getter"),
        (0x266, "???"),
        (0x267, "aep_dummy"),
        (0x268, "kind"),
        (0x269, "_kind"),
        (0x26A, "org"),
        (0x26B, "flashdevelop"),
        (0x26C, "utils"),
        (0x26D, "FlashConnect"),
        (0x26E, "path"),
        (0x26F, "if"),
        (0x270, "notif"),
        (0x271, "not"),
        (0x272, "A"),
        (0x273, "dmy0273"),
        (0x274, "C"),
        (0x275, "D"),
        (0x276, "dmy0276"),
        (0x277, "F"),
        (0x278, "G"),
        (0x279, "H"),
        (0x27A, "I"),
        (0x27B, "J"),
        (0x27C, "K"),
        (0x27D, "dmy027d"),
        (0x27E, "M"),
        (0x27F, "N"),
        (0x280, "O"),
        (0x281, "P"),
        (0x282, "Q"),
        (0x283, "dmy0283"),
        (0x284, "S"),
        (0x285, "dmy0285"),
        (0x286, "U"),
        (0x287, "V"),
        (0x288, "W"),
        (0x289, "X"),
        (0x28A, "Y"),
        (0x28B, "Z"),
        (0x28C, "fullscreen"),
        (0x28D, "showmenu"),
        (0x28E, "allowscale"),
        (0x28F, "quit"),
        (0x290, "true"),
        (0x291, "false"),
        (0x292, "clamp"),
        (0x293, "ignore"),
        (0x294, "wrap"),
        (0x295, "unknown"),
        (0x296, "bigEndian"),
        (0x297, "littleEndian"),
        (0x298, "fragment"),
        (0x299, "vertex"),
        (0x29A, "bgra"),
        (0x29B, "bgraPacked4444"),
        (0x29C, "bgrPacked565"),
        (0x29D, "compressed"),
        (0x29E, "compressedAlpha"),
        (0x29F, "bytes4"),
        (0x2A0, "float1"),
        (0x2A1, "float2"),
        (0x2A2, "float3"),
        (0x2A3, "float4"),
        (0x2A4, "super"),
        (0x2A5, "axisAngle"),
        (0x2A6, "eulerAngles"),
        (0x2A7, "quaternion"),
        (0x2A8, "orientationStyle"),
        # Layer depths
        (0x2E0, "_level0"),
        (0x2E1, "_level1"),
        (0x2E2, "_level2"),
        (0x2E3, "_level3"),
        (0x2E4, "_level4"),
        (0x2E5, "_level5"),
        (0x2E6, "_level6"),
        (0x2E7, "_level7"),
        (0x2E8, "_level8"),
        (0x2E9, "_level9"),
        (0x2EA, "_level10"),
        (0x2EB, "_level11"),
        (0x2EC, "_level12"),
        (0x2ED, "_level13"),
        (0x2EE, "_level14"),
        (0x2EF, "_level15"),
        # System objects
        (0x300, "System"),
        (0x301, "Stage"),
        (0x302, "Key"),
        (0x303, "Math"),
        (0x304, "flash"),
        (0x305, "MovieClip"),
        (0x306, "String"),
        (0x307, "TextField"),
        (0x308, "Color"),
        (0x309, "Date"),
        (0x30A, "SharedObject"),
        (0x30B, "Mouse"),
        (0x30C, "Object"),
        (0x30D, "Sound"),
        (0x30E, "Number"),
        (0x30F, "Array"),
        (0x310, "XML"),
        (0x311, "TextFormat"),
        (0x312, "display"),
        (0x313, "geom"),
        (0x314, "Matrix"),
        (0x315, "Point"),
        (0x316, "BitmapData"),
        (0x317, "data"),
        (0x318, "filters"),
        (0x319, "ColorMatrixFilter"),
        (0x31A, "Function"),
        (0x31B, "XMLNode"),
        (0x31C, "aplib"),
        (0x31D, "Transform"),
        (0x31E, "ColorTransform"),
        (0x31F, "Rectangle"),
        (0x320, "asdlib"),
        (0x321, "XMLController"),
        (0x322, "eManager"),
        (0x323, "Error"),
        (0x324, "MovieClipLoader"),
        (0x325, "UndefChecker"),
        (0x326, "int"),
        (0x327, "uint"),
        (0x328, "Vector"),
        (0x329, "Event"),
        (0x32A, "MouseEvent"),
        (0x32B, "Matrix3D"),
        (0x32C, "Keyboard"),
        (0x32D, "DisplayObject"),
        (0x32E, "Dictionary"),
        (0x32F, "BlendMode"),
        (0x330, "DisplayObjectContainer"),
        (0x331, "Class"),
        (0x332, "EventDispatcher"),
        (0x333, "PerspectiveProjection"),
        (0x334, "Vector3D"),
        (0x335, "aplib3"),
        (0x336, "SoundChannel"),
        (0x337, "Loader"),
        (0x338, "URLRequest"),
        (0x339, "Sprite"),
        (0x33A, "KeyboardEvent"),
        (0x33B, "Timer"),
        (0x33C, "TimerEvent"),
        (0x33D, "asdlib3"),
        (0x33E, "eManager3"),
        (0x33F, "LoaderInfo"),
        (0x340, "ProgressEvent"),
        (0x341, "IOErrorEvent"),
        (0x342, "Graphics"),
        (0x343, "LineScaleMode"),
        (0x344, "CapsStyle"),
        (0x345, "JointStyle"),
        (0x346, "GradientType"),
        (0x347, "SpreadMethod"),
        (0x348, "InterpolationMethod"),
        (0x349, "GraphicsPathCommand"),
        (0x34A, "GraphicsPathWinding"),
        (0x34B, "TriangleCulling"),
        (0x34C, "GraphicsBitmapFill"),
        (0x34D, "GraphicsEndFill"),
        (0x34E, "GraphicsGradientFill"),
        (0x34F, "GraphicsPath"),
        (0x350, "GraphicsSolidFill"),
        (0x351, "GraphicsStroke"),
        (0x352, "GraphicsTrianglePath"),
        (0x353, "IGraphicsData"),
        (0x354, "external"),
        (0x355, "ExternalInterface"),
        (0x356, "Scene"),
        (0x357, "FrameLabel"),
        (0x358, "Shape"),
        (0x359, "SimpleButton"),
        (0x35A, "Bitmap"),
        (0x35B, "StageQuality"),
        (0x35C, "InteractiveObject"),
        (0x35D, "MotionBase"),
        (0x35E, "KeyframeBase"),
        (0x35F, "XMLList"),
        (0x360, "StageAlign"),
        (0x361, "StageScaleMode"),
        (0x362, "AnimatorBase"),
        (0x363, "Animator3D"),
        (0x364, "URLLoader"),
        (0x365, "Capabilities"),
        (0x366, "Aweener"),
        (0x367, "Aweener3"),
        (0x368, "SoundTransform"),
        (0x369, "Namespace"),
        (0x36A, "RegExp"),
        (0x36B, "afplib"),
        (0x36C, "afplib3"),
        (0x36D, "ByteArray"),
        (0x36E, "TextFormatAlign"),
        (0x36F, "TextFieldType"),
        (0x370, "TextFieldAutoSize"),
        (0x371, "SecurityErrorEvent"),
        (0x372, "ApplicationDomain"),
        (0x373, "TextEvent"),
        (0x374, "ErrorEvent"),
        (0x375, "LoaderContext"),
        (0x376, "QName"),
        (0x377, "IllegalOperationError"),
        (0x378, "URLLoaderDataFormat"),
        (0x379, "Security"),
        (0x37A, "DropShadowFilter"),
        (0x37B, "ReferenceError"),
        (0x37C, "Proxy"),
        (0x37D, "XMLSocket"),
        (0x37E, "DataEvent"),
        (0x37F, "Font"),
        (0x380, "IEventDispatcher"),
        (0x381, "LocalConnection"),
        (0x382, "ActionScriptVersion"),
        (0x383, "MouseCursor"),
        (0x384, "TypeError"),
        (0x385, "FocusEvent"),
        (0x386, "AntiAliasType"),
        (0x387, "GridFitType"),
        (0x388, "ArgumentError"),
        (0x389, "BitmapFilterType"),
        (0x38A, "BevelFilter"),
        (0x38B, "BitmapFilter"),
        (0x38C, "BitmapFilterQuality"),
        (0x38D, "XMLController3"),
        (0x38E, "URLVariables"),
        (0x38F, "URLRequestMethod"),
        (0x390, "aeplib"),
        (0x391, "BlurFilter"),
        (0x392, "Stage3D"),
        (0x393, "Context3D"),
        (0x394, "Multitouch"),
        (0x395, "Script"),
        (0x396, "AccessibilityProperties"),
        (0x397, "StaticText"),
        (0x398, "MorphShape"),
        (0x399, "BitmapDataChannel"),
        (0x39A, "DisplacementMapFilter"),
        (0x39B, "GlowFilter"),
        (0x39C, "DisplacementMapFilterMode"),
        (0x39D, "AnimatorFactoryBase"),
        (0x39E, "Endian"),
        (0x39F, "IOError"),
        (0x3A0, "EOFError"),
        (0x3A1, "Context3DTextureFormat"),
        (0x3A2, "Context3DProgramType"),
        (0x3A3, "TextureBase"),
        (0x3A4, "VertexBuffer3D"),
        (0x3A5, "IndexBuffer3D"),
        (0x3A6, "Program3D"),
        (0x3A7, "NativeMenuItem"),
        (0x3A8, "ContextMenuItem"),
        (0x3A9, "NativeMenu"),
        (0x3AA, "ContextMenu"),
        (0x3AB, "ContextMenuEvent"),
        (0x3AC, "Context3DVertexBufferFormat"),
        (0x3AD, "TouchEvent"),
        (0x3AE, "b2Vec2"),
        (0x3AF, "b2Math"),
        (0x3B0, "b2Transform"),
        (0x3B1, "b2Mat22"),
        (0x3B2, "b2Sweep"),
        (0x3B3, "b2AABB"),
        (0x3B4, "b2Vec3"),
        (0x3B5, "b2Mat33"),
        (0x3B6, "b2DistanceProxy"),
        (0x3B7, "b2Shape"),
        (0x3B8, "b2CircleShape"),
        (0x3B9, "b2PolygonShape"),
        (0x3BA, "b2MassData"),
        (0x3BB, "b2DistanceInput"),
        (0x3BC, "b2DistanceOutput"),
        (0x3BD, "b2SimplexCache"),
        (0x3BE, "b2Simplex"),
        (0x3BF, "b2SimplexVertex"),
        (0x3C0, "b2Distance"),
        (0x3C1, "Orientation3D"),
        (0x3C2, "GradientGlowFilter"),
        (0x3C3, "GradientBevelFilter"),
        # XML functions
        (0x400, "afp_prop_init"),
        (0x401, "afp_prop"),
        (0x402, "afp_prop_dummy"),
        (0x403, "afp_prop_destroy"),
        (0x404, "afp_sync"),
        (0x405, "afp_node_search"),
        (0x406, "afp_node_value"),
        (0x407, "afp_node_array_value"),
        (0x408, "afp_complete"),
        (0x409, "afp_sound_fade_in"),
        (0x40A, "afp_sound_fade_out"),
        (0x40B, "afp_make_gradient_data"),
        (0x40C, "afp_make_alpha_texture"),
        (0x40D, "afp_node_set_value"),
        (0x40E, "afp_node_date_value"),
        (0x40F, "afp_node_num_value"),
        (0x410, "afp_node_array_num_value"),
        (0x411, "afp_node_child"),
        (0x412, "afp_node_parent"),
        (0x413, "afp_node_next"),
        (0x414, "afp_node_prev"),
        (0x415, "afp_node_last"),
        (0x416, "afp_node_first"),
        (0x417, "afp_node_next_same_name"),
        (0x418, "afp_node_prev_same_name"),
        (0x419, "afp_node_name"),
        (0x41A, "afp_node_absolute_path"),
        (0x41B, "afp_node_has_parent"),
        (0x41C, "afp_node_has_child"),
        (0x41D, "afp_node_has_sibling"),
        (0x41E, "afp_node_has_attrib"),
        (0x41F, "afp_node_has_same_name_sibling"),
        # System functions
        (0x420, "updateAfterEvent"),
        (0x421, "parseInt"),
        (0x422, "parseFloat"),
        (0x423, "Boolean"),
        (0x424, "setInterval"),
        (0x425, "clearInterval"),
        (0x426, "escape"),
        (0x427, "ASSetPropFlags"),
        (0x428, "unescape"),
        (0x429, "isNaN"),
        (0x42A, "isFinite"),
        (0x42B, "trace"),
        (0x42C, "addFrameScript"),
        (0x42D, "getDefinitionByName"),
        (0x42E, "getTimer"),
        (0x42F, "setTimeout"),
        (0x430, "clearTimeout"),
        (0x431, "escapeMultiByte"),
        (0x432, "unescapeMultiByte"),
        (0x433, "getQualifiedClassName"),
        (0x434, "describeType"),
        (0x435, "decodeURI"),
        (0x436, "encodeURI"),
        (0x437, "decodeURIComponent"),
        (0x438, "encodeURIComponent"),
        (0x439, "registerClassAlias"),
        (0x43A, "getClassByAlias"),
        (0x43B, "getQualifiedSuperclassName"),
        (0x43C, "isXMLName"),
        (0x43D, "fscommand"),
        # Current movie manipulation functions.
        (0x440, "stop"),
        (0x441, "play"),
        (0x442, "gotoAndPlay"),
        (0x443, "gotoAndStop"),
        (0x444, "prevFrame"),
        (0x445, "nextFrame"),
        (0x446, "createEmptyMovieClip"),
        (0x447, "duplicateMovieClip"),
        (0x448, "attachMovie"),
        (0x449, "attachBitmap"),
        (0x44A, "removeMovieClip"),
        (0x44B, "unloadMovie"),
        (0x44C, "loadMovie"),
        (0x44D, "loadVariables"),
        (0x44E, "startDrag"),
        (0x44F, "stopDrag"),
        (0x450, "setMask"),
        (0x451, "hitTest"),
        (0x452, "lineStyle"),
        (0x453, "lineGradientStyle"),
        (0x454, "beginFill"),
        (0x455, "beginBitmapFill"),
        (0x456, "endFill"),
        (0x457, "moveTo"),
        (0x458, "lineTo"),
        (0x459, "curveTo"),
        (0x45A, "clear"),
        (0x45B, "getBytesLoaded"),
        (0x45C, "getBytesTotal"),
        (0x45D, "getDepth"),
        (0x45E, "getNextHighestDepth"),
        (0x45F, "swapDepths"),
        (0x460, "localToGlobal"),
        (0x461, "beginGradientFill"),
        (0x462, "getSWFVersion"),
        (0x463, "getRect"),
        (0x464, "getBounds"),
        (0x465, "getInstanceAtDepth"),
        (0x466, "getURL"),
        (0x467, "globalToLocal"),
        (0x468, "nextScene"),
        (0x469, "prevScene"),
        (0x46A, "getChildByName"),
        (0x46B, "getChildIndex"),
        (0x46C, "addChild"),
        (0x46D, "removeChildAt"),
        (0x46E, "getChildAt"),
        (0x46F, "setChildIndex"),
        (0x470, "lineBitmapStyle"),
        (0x471, "hitTestObject"),
        (0x472, "hitTestPoint"),
        (0x473, "addChildAt"),
        (0x474, "removeChild"),
        (0x475, "swapChildren"),
        (0x476, "swapChildrenAt"),
        (0x477, "getObjectsUnderPoint"),
        (0x478, "createTextField"),
        (0x479, "local3DToGlobal"),
        (0x47A, "globalToLocal3D"),
        # System object manipulation functions.
        (0x480, "toString"),
        (0x481, "distance"),
        (0x482, "translate"),
        (0x483, "rotate"),
        (0x484, "scale"),
        (0x485, "clone"),
        (0x486, "transformPoint"),
        (0x487, "add"),
        (0x488, "cos"),
        (0x489, "sin"),
        (0x48A, "sqrt"),
        (0x48B, "atan2"),
        (0x48C, "log"),
        (0x48D, "abs"),
        (0x48E, "floor"),
        (0x48F, "ceil"),
        (0x490, "round"),
        (0x491, "pow"),
        (0x492, "max"),
        (0x493, "min"),
        (0x494, "random"),
        (0x495, "acos"),
        (0x496, "asin"),
        (0x497, "atan"),
        (0x498, "tan"),
        (0x499, "exp"),
        (0x49A, "getRGB"),
        (0x49B, "setRGB"),
        (0x49C, "getTransform"),
        (0x49D, "setTransform"),
        (0x49E, "fromCharCode"),
        (0x49F, "substr"),
        (0x4A0, "substring"),
        (0x4A1, "toUpperCase"),
        (0x4A2, "toLowerCase"),
        (0x4A3, "indexOf"),
        (0x4A4, "lastIndexOf"),
        (0x4A5, "charAt"),
        (0x4A6, "charCodeAt"),
        (0x4A7, "split"),
        (0x4A8, "concat"),
        (0x4A9, "getFullYear"),
        (0x4AA, "getUTCFullYear"),
        (0x4AB, "getMonth"),
        (0x4AC, "getUTCMonth"),
        (0x4AD, "getDate"),
        (0x4AE, "getUTCDate"),
        (0x4AF, "getDay"),
        (0x4B0, "getHours"),
        (0x4B1, "getUTCHours"),
        (0x4B2, "getMinutes"),
        (0x4B3, "getUTCMinutes"),
        (0x4B4, "getSeconds"),
        (0x4B5, "getUTCSeconds"),
        (0x4B6, "getTime"),
        (0x4B7, "getTimezoneOffset"),
        (0x4B8, "UTC"),
        (0x4B9, "createElement"),
        (0x4BA, "appendChild"),
        (0x4BB, "createTextNode"),
        (0x4BC, "parseXML"),
        (0x4BD, "load"),
        (0x4BE, "hasChildNodes"),
        (0x4BF, "cloneNode"),
        (0x4C0, "removeNode"),
        (0x4C1, "loadInAdvance"),
        (0x4C2, "createGradientBox"),
        (0x4C3, "loadBitmap"),
        (0x4C4, "hide"),
        (0x4C5, "show"),
        (0x4C6, "addListener"),
        (0x4C7, "removeListener"),
        (0x4C8, "isDown"),
        (0x4C9, "getCode"),
        (0x4CA, "getAscii"),
        (0x4CB, "attachSound"),
        (0x4CC, "start"),
        (0x4CD, "getVolume"),
        (0x4CE, "setVolume"),
        (0x4CF, "setPan"),
        (0x4D0, "loadSound"),
        (0x4D1, "setTextFormat"),
        (0x4D2, "getTextFormat"),
        (0x4D3, "push"),
        (0x4D4, "pop"),
        (0x4D5, "slice"),
        (0x4D6, "splice"),
        (0x4D7, "reverse"),
        (0x4D8, "sort"),
        (0x4D9, "flush"),
        (0x4DA, "getLocal"),
        (0x4DB, "shift"),
        (0x4DC, "unshift"),
        (0x4DD, "registerClass"),
        (0x4DE, "getUTCDay"),
        (0x4DF, "getMilliseconds"),
        (0x4E0, "getUTCMilliseconds"),
        (0x4E1, "addProperty"),
        (0x4E2, "hasOwnProperty"),
        (0x4E3, "isPropertyEnumerable"),
        (0x4E4, "isPrototypeOf"),
        (0x4E5, "unwatch"),
        (0x4E6, "valueOf"),
        (0x4E7, "watch"),
        (0x4E8, "apply"),
        (0x4E9, "call"),
        (0x4EA, "contains"),
        (0x4EB, "containsPoint"),
        (0x4EC, "containsRectangle"),
        (0x4ED, "equals"),
        (0x4EE, "inflate"),
        (0x4EF, "inflatePoint"),
        (0x4F0, "intersection"),
        (0x4F1, "intersects"),
        (0x4F2, "isEmpty"),
        (0x4F3, "offset"),
        (0x4F4, "offsetPoint"),
        (0x4F5, "setEmpty"),
        (0x4F6, "union"),
        (0x4F7, "interpolate"),
        (0x4F8, "join"),
        (0x4F9, "loadClip"),
        (0x4FA, "getProgress"),
        (0x4FB, "unloadClip"),
        (0x4FC, "polar"),
        (0x4FD, "sortOn"),
        (0x4FE, "containsRect"),
        (0x4FF, "getYear"),
        # Event constants
        (0x500, "onKeyDown"),
        (0x501, "onKeyUp"),
        (0x502, "onMouseDown"),
        (0x503, "onMouseUp"),
        (0x504, "onMouseMove"),
        (0x505, "onLoad"),
        (0x506, "onEnterFrame"),
        (0x507, "onUnload"),
        (0x508, "onRollOver"),
        (0x509, "onRollOut"),
        (0x50A, "onPress"),
        (0x50B, "onRelease"),
        (0x50C, "onReleaseOutside"),
        (0x50D, "onData"),
        (0x50E, "onSoundComplete"),
        (0x50F, "onDragOver"),
        (0x510, "onDragOut"),
        (0x511, "onMouseWheel"),
        (0x512, "onLoadError"),
        (0x513, "onLoadComplete"),
        (0x514, "onLoadInit"),
        (0x515, "onLoadProgress"),
        (0x516, "onLoadStart"),
        (0x517, "onComplete"),
        (0x518, "onCompleteParams"),
        (0x519, "ononCompleteScope"),
        (0x51A, "onStart"),
        (0x51B, "onStartParams"),
        (0x51C, "onStartScope"),
        (0x51D, "onUpdate"),
        (0x51E, "onUpdateParams"),
        (0x51F, "onUpdateScope"),
        (0x520, "onKeyPress"),
        (0x521, "onInitialize"),
        (0x522, "onConstruct"),
        (0x5C0, "scaleX"),
        (0x5C1, "scaleY"),
        (0x5C2, "currentFrame"),
        (0x5C3, "totalFrames"),
        (0x5C4, "visible"),
        (0x5C5, "rotation"),
        (0x5C6, "framesLoaded"),
        (0x5C7, "dropTarget"),
        (0x5C8, "focusRect"),
        (0x5C9, "mouseX"),
        (0x5CA, "mouseY"),
        (0x5CB, "root"),
        (0x5CC, "parent"),
        (0x5CD, "stage"),
        (0x5CE, "currentLabel"),
        (0x5CF, "currentLabels"),
        (0x5D0, "currentFrameLabel"),
        (0x5D1, "currentScene"),
        (0x5D2, "scenes"),
        (0x5D3, "rotationX"),
        (0x5D4, "rotationY"),
        (0x5D5, "rotationZ"),
        (0x5D6, "quality"),
        (0x5D7, "skewX"),
        (0x5D8, "skewY"),
        (0x5D9, "rotationConcat"),
        (0x5DA, "useRotationConcat"),
        (0x5DB, "scaleZ"),
        (0x5DC, "isPlaying"),
        # Key constants
        (0x600, "BACKSPACE"),
        (0x601, "CAPSLOCK"),
        (0x602, "CONTROL"),
        (0x603, "DELETEKEY"),
        (0x604, "DOWN"),
        (0x605, "END"),
        (0x606, "ENTER"),
        (0x607, "ESCAPE"),
        (0x608, "HOME"),
        (0x609, "INSERT"),
        (0x60A, "LEFT"),
        (0x60B, "PGDN"),
        (0x60C, "PGUP"),
        (0x60D, "RIGHT"),
        (0x60E, "SHIFT"),
        (0x60F, "SPACE"),
        (0x610, "TAB"),
        (0x611, "UP"),
        (0x612, "ARROW"),
        (0x613, "AUTO"),
        (0x614, "BUTTON"),
        (0x615, "HAND"),
        (0x616, "IBEAM"),
        # Some sort of sorting constants.
        (0x620, "CASEINSENSITIVE"),
        (0x621, "DESCENDING"),
        (0x622, "UNIQUESORT"),
        (0x623, "RETURNINDEXEDARRAY"),
        (0x624, "NUMERIC"),
        (0x640, "ADD"),
        (0x641, "ALPHA"),
        (0x642, "DARKEN"),
        (0x643, "DIFFERENCE"),
        (0x644, "ERASE"),
        (0x645, "HARDLIGHT"),
        (0x646, "INVERT"),
        (0x647, "LAYER"),
        (0x648, "LIGHTEN"),
        (0x649, "MULTIPLY"),
        (0x64A, "NORMAL"),
        (0x64B, "OVERLAY"),
        (0x64C, "SCREEN"),
        (0x64D, "SHADER"),
        (0x64E, "SUBTRACT"),
        (0x660, "dmy0660"),
        (0x661, "NONE"),
        (0x662, "VERTICAL"),
        (0x663, "HORIZONTAL"),
        (0x664, "ROUND"),
        (0x665, "SQUARE"),
        (0x666, "BEVEL"),
        (0x667, "MITER"),
        (0x668, "LINEAR"),
        (0x669, "RADIAL"),
        (0x66A, "PAD"),
        (0x66B, "REFLECT"),
        (0x66C, "REPEAT"),
        (0x66D, "LINEAR_RGB"),
        (0x66E, "NO_OP"),
        (0x66F, "MOVE_TO"),
        (0x670, "LINE_TO"),
        (0x671, "CURVE_TO"),
        (0x672, "WIDE_MOVE_TO"),
        (0x673, "WIDE_LINE_TO"),
        (0x674, "EVEN_ODD"),
        (0x675, "NON_ZERO"),
        (0x676, "NEGATIVE"),
        (0x677, "POSITIVE"),
        (0x678, "FRAGMENT"),
        (0x679, "VERTEX"),
        (0x67A, "BGRA"),
        (0x67B, "BGRA_PACKED"),
        (0x67C, "BGR_PACKED"),
        (0x67D, "COMPRESSED"),
        (0x67E, "COMPRESSED_ALPHA"),
        (0x67F, "BYTES_4"),
        (0x680, "FLOAT_1"),
        (0x681, "FLOAT_2"),
        (0x682, "FLOAT_3"),
        (0x683, "FLOAT_4"),
        (0x684, "e_unknownShape"),
        (0x685, "e_circleShape"),
        (0x686, "e_polygonShape"),
        (0x687, "e_edgeShape"),
        (0x688, "e_shapeTypeCount"),
        (0x689, "CUBIC_CURVE_TO"),
        (0x690, "BOTTOM"),
        (0x691, "BOTTOM_LEFT"),
        (0x692, "BOTTOM_RIGHT"),
        (0x693, "TOP"),
        (0x694, "TOP_LEFT"),
        (0x695, "TOP_RIGHT"),
        (0x696, "EXACT_FIT"),
        (0x697, "NO_BORDER"),
        (0x698, "NO_SCALE"),
        (0x699, "SHOW_ALL"),
        (0x6A0, "CENTER"),
        (0x6A1, "JUSTIFY"),
        (0x6A2, "dmy06a2"),
        (0x6A3, "dmy06a3"),
        (0x6A4, "dmy06a4"),
        (0x6A5, "dmy06a5"),
        (0x6A6, "dmy06a6"),
        (0x6A7, "dmy06a7"),
        (0x6A8, "dmy06a8"),
        (0x6A9, "DYNAMIC"),
        (0x6AA, "INPUT"),
        (0x6AB, "ADVANCED"),
        (0x6AC, "PIXEL"),
        (0x6AD, "SUBPIXEL"),
        (0x6B0, "BINARY"),
        (0x6B1, "TEXT"),
        (0x6B2, "VARIABLES"),
        (0x6C0, "FULL"),
        (0x6C1, "INNER"),
        (0x6C2, "OUTER"),
        (0x6C3, "RED"),
        (0x6C4, "GREEN"),
        (0x6C5, "BLUE"),
        (0x6C6, "CLAMP"),
        (0x6C7, "COLOR"),
        (0x6C8, "IGNORE"),
        (0x6C9, "WRAP"),
        (0x6D0, "DELETE"),
        (0x6D1, "GET"),
        (0x6D2, "HEAD"),
        (0x6D3, "OPTIONS"),
        (0x6D4, "POST"),
        (0x6D5, "PUT"),
        (0x6D6, "BIG_ENDIAN"),
        (0x6D7, "LITTLE_ENDIAN"),
        (0x6D8, "AXIS_ANGLE"),
        (0x6D9, "EULER_ANGLES"),
        (0x6DA, "QUATERNION"),
        (0x6F0, "NUMBER_0"),
        (0x6F1, "NUMBER_1"),
        (0x6F2, "NUMBER_2"),
        (0x6F3, "NUMBER_3"),
        (0x6F4, "NUMBER_4"),
        (0x6F5, "NUMBER_5"),
        (0x6F6, "NUMBER_6"),
        (0x6F7, "NUMBER_7"),
        (0x6F8, "NUMBER_8"),
        (0x6F9, "NUMBER_9"),
        # Shape constants?
        (0x700, "redMultiplier"),
        (0x701, "greenMultiplier"),
        (0x702, "blueMultiplier"),
        (0x703, "alphaMultiplier"),
        (0x704, "redOffset"),
        (0x705, "greenOffset"),
        (0x706, "blueOffset"),
        (0x707, "alphaOffset"),
        (0x708, "rgb"),
        (0x709, "bottom"),
        (0x70A, "bottomRight"),
        (0x70B, "top"),
        (0x70C, "topLeft"),
        (0x70D, "LOW"),
        (0x70E, "MEDIUM"),
        (0x70F, "HIGH"),
        (0x710, "BEST"),
        (0x711, "name"),
        (0x712, "message"),
        (0x713, "bytesLoaded"),
        (0x714, "bytesTotal"),
        (0x715, "once"),
        (0x716, "MAX_VALUE"),
        (0x717, "MIN_VALUE"),
        (0x718, "NEGATIVE_INFINITY"),
        (0x719, "POSITIVE_INFINITY"),
        (0x71A, "stageWidth"),
        (0x71B, "stageHeight"),
        (0x71C, "frame"),
        (0x71D, "numFrames"),
        (0x71E, "labels"),
        (0x71F, "currentTarget"),
        (0x720, "void"),
        (0x721, "fixed"),
        (0x722, "rawData"),
        (0x723, "type"),
        (0x724, "focalLength"),
        (0x725, "fieldOfView"),
        (0x726, "projectionCenter"),
        (0x727, "E"),
        (0x728, "LN10"),
        (0x729, "LN2"),
        (0x72A, "LOG10E"),
        (0x72B, "LOG2E"),
        (0x72C, "PI"),
        (0x72D, "SQRT1_2"),
        (0x72E, "SQRT2"),
        (0x72F, "stageX"),
        (0x730, "stageY"),
        (0x731, "localX"),
        (0x732, "localY"),
        (0x733, "tintColor"),
        (0x734, "tintMultiplier"),
        (0x735, "brightness"),
        (0x736, "delay"),
        (0x737, "repeatCount"),
        (0x738, "currentCount"),
        (0x739, "running"),
        (0x73A, "charCode"),
        (0x73B, "keyCode"),
        (0x73C, "altKey"),
        (0x73D, "ctrlKey"),
        (0x73E, "shiftKey"),
        (0x73F, "useCodePage"),
        (0x740, "contentLoaderInfo"),
        (0x741, "loaderURL"),
        (0x742, "loader"),
        (0x743, "fullYear"),
        (0x744, "fullYearUTC"),
        (0x745, "month"),
        (0x746, "monthUTC"),
        (0x747, "date"),
        (0x748, "dateUTC"),
        (0x749, "day"),
        (0x74A, "dayUTC"),
        (0x74B, "hours"),
        (0x74C, "hoursUTC"),
        (0x74D, "minutes"),
        (0x74E, "minutesUTC"),
        (0x74F, "seconds"),
        (0x750, "secondsUTC"),
        (0x751, "milliseconds"),
        (0x752, "millisecondsUTC"),
        (0x753, "timezoneOffset"),
        (0x754, "time"),
        (0x755, "joints"),
        (0x756, "fill"),
        (0x757, "colors"),
        (0x758, "commands"),
        (0x759, "miterLimit"),
        (0x75A, "alphas"),
        (0x75B, "ratios"),
        (0x75C, "bitmapData"),
        (0x75D, "vertices"),
        (0x75E, "uvtData"),
        (0x75F, "indices"),
        (0x760, "parameters"),
        (0x761, "frameRate"),
        (0x762, "low"),
        (0x763, "medium"),
        (0x764, "high"),
        (0x765, "best"),
        (0x766, "index"),
        (0x767, "blank"),
        (0x768, "is3D"),
        (0x769, "scaleMode"),
        (0x76A, "frameEvent"),
        (0x76B, "motion"),
        (0x76C, "transformationPoint"),
        (0x76D, "transformationPointZ"),
        (0x76E, "sceneName"),
        (0x76F, "targetParent"),
        (0x770, "targetName"),
        (0x771, "initialPosition"),
        (0x772, "children"),
        (0x773, "child"),
        (0x774, "playerType"),
        (0x775, "os"),
        (0x776, "capabilities"),
        (0x777, "transition"),
        (0x778, "transitionParameters"),
        (0x779, "useFrames"),
        (0x77A, "_color_redMultiplier"),
        (0x77B, "_color_redOffset"),
        (0x77C, "_color_greenMultiplier"),
        (0x77D, "_color_greenOffset"),
        (0x77E, "_color_blueMultiplier"),
        (0x77F, "_color_blueOffset"),
        (0x780, "_color_alphaMultiplier"),
        (0x781, "_color_alphaOffset"),
        (0x782, "_color"),
        (0x783, "soundTransform"),
        (0x784, "volume"),
        (0x785, "uri"),
        (0x786, "prefix"),
        (0x787, "content"),
        (0x788, "contentType"),
        (0x789, "swfVersion"),
        (0x78A, "input"),
        (0x78B, "source"),
        (0x78C, "lastIndex"),
        (0x78D, "stageFocusRect"),
        (0x78E, "currentDomain"),
        (0x78F, "applicationDomain"),
        (0x790, "parentDomain"),
        (0x791, "dataFormat"),
        (0x792, "digest"),
        (0x793, "errorID"),
        (0x794, "available"),
        (0x795, "client"),
        (0x796, "actionScriptVersion"),
        (0x797, "ACTIONSCRIPT2"),
        (0x798, "ACTIONSCRIPT3"),
        (0x799, "delta"),
        (0x79A, "cursor"),
        (0x79B, "buttonDown"),
        (0x79C, "motionArray"),
        (0x79D, "spanStart"),
        (0x79E, "spanEnd"),
        (0x79F, "placeholderName"),
        (0x7A0, "instanceFactoryClass"),
        (0x7A1, "instance"),
        (0x7A2, "method"),
        (0x7A3, "requestHeaders"),
        (0x7A4, "info"),
        (0x7A5, "dotall"),
        (0x7A6, "extended"),
        (0x7A7, "global"),
        (0x7A8, "ignoreCase"),
        (0x7A9, "X_AXIS"),
        (0x7AA, "Y_AXIS"),
        (0x7AB, "Z_AXIS"),
        (0x7AC, "lengthSquared"),
        (0x7AD, "dps"),
        (0x7AE, "from0"),
        (0x7AF, "_text"),
        (0x7B0, "_text_sound"),
        (0x7B1, "blurX"),
        (0x7B2, "blurY"),
        (0x7B3, "step"),
        (0x7B4, "spc"),
        (0x7B5, "stage3Ds"),
        (0x7B6, "context3D"),
        (0x7B7, "version"),
        (0x7B8, "accessibilityProperties"),
        (0x7B9, "description"),
        (0x7BA, "adjustColorBrightness"),
        (0x7BB, "adjustColorContrast"),
        (0x7BC, "adjustColorSaturation"),
        (0x7BD, "adjustColorHue"),
        (0x7BE, "strength"),
        (0x7BF, "angle"),
        (0x7C0, "knockout"),
        (0x7C1, "hideObject"),
        (0x7C2, "manufacturer"),
        (0x7C3, "smoothing"),
        (0x7C4, "rect"),
        (0x7C5, "transparent"),
        (0x7C6, "mapBitmap"),
        (0x7C7, "mapPoint"),
        (0x7C8, "componentX"),
        (0x7C9, "componentY"),
        (0x7CA, "mode"),
        (0x7CB, "highlightColor"),
        (0x7CC, "highlightAlpha"),
        (0x7CD, "shadowColor"),
        (0x7CE, "shadowAlpha"),
        (0x7CF, "endian"),
        (0x7D0, "_scale"),
        (0x7D1, "transitionParams"),
        (0x7D2, "_text_color"),
        (0x7D3, "_text_color_r"),
        (0x7D4, "_text_color_g"),
        (0x7D5, "_text_color_b"),
        (0x7D6, "cancelable"),
        (0x7D7, "col1"),
        (0x7D8, "col2"),
        (0x7D9, "localCenter"),
        (0x7DA, "t0"),
        (0x7DB, "a0"),
        (0x7DC, "c0"),
        (0x7DD, "lowerBound"),
        (0x7DE, "upperBound"),
        (0x7DF, "col3"),
        (0x7E0, "mass"),
        (0x7E1, "m_vertices"),
        (0x7E2, "m_vertexCount"),
        (0x7E3, "m_radius"),
        (0x7E4, "m_p"),
        (0x7E5, "m_normals"),
        (0x7E6, "m_type"),
        (0x7E7, "m_centroid"),
        (0x7E8, "proxyA"),
        (0x7E9, "proxyB"),
        (0x7EA, "transformA"),
        (0x7EB, "transformB"),
        (0x7EC, "useRadii"),
        (0x7ED, "pointA"),
        (0x7EE, "pointB"),
        (0x7EF, "iterations"),
        (0x7F0, "count"),
        (0x7F1, "metric"),
        (0x7F2, "indexA"),
        (0x7F3, "indexB"),
        (0x7F4, "determinant"),
        # Some more system functions?
        (0x800, "sound_play"),
        (0x801, "sound_stop"),
        (0x802, "sound_stop_all"),
        (0x803, "set_top_mc"),
        (0x804, "set_controlled_XML"),
        (0x805, "set_config_XML"),
        (0x806, "set_data_top"),
        (0x807, "attach_event"),
        (0x808, "detach_event"),
        (0x809, "set"),
        (0x80A, "get"),
        (0x80B, "ready"),
        (0x80C, "afp_available"),
        (0x80D, "controller_available"),
        (0x80E, "push_state"),
        (0x80F, "pop_state"),
        (0x810, "afp_verbose_action"),
        (0x811, "sound_fadeout"),
        (0x812, "sound_fadeout_all"),
        (0x813, "deepPlay"),
        (0x814, "deepStop"),
        (0x815, "deepGotoAndPlay"),
        (0x816, "deepGotoAndStop"),
        (0x817, "detach_event_all"),
        (0x818, "detach_event_id"),
        (0x819, "detach_event_obj"),
        (0x81A, "get_version"),
        (0x81B, "get_version_str"),
        (0x81C, "addAween"),
        (0x81D, "addCaller"),
        (0x81E, "registerSpecialProperty"),
        (0x81F, "registerSpecialPropertySplitter"),
        (0x820, "registerTransition"),
        (0x821, "removeAllAweens"),
        (0x822, "removeAweens"),
        (0x823, "use_konami_lib"),
        (0x824, "sound_volume"),
        (0x825, "sound_volume_all"),
        (0x826, "afp_verbose_script"),
        (0x827, "afp_node_check_value"),
        (0x828, "afp_node_check"),
        (0x829, "get_version_full_str"),
        (0x82A, "set_debug"),
        (0x82B, "num2str_comma"),
        (0x82C, "areacode2str"),
        (0x82D, "num2str_period"),
        (0x82E, "get_columns"),
        (0x82F, "num2mc"),
        (0x830, "warning"),
        (0x831, "fatal"),
        (0x832, "aep_set_frame_control"),
        (0x833, "aep_set_rect_mask"),
        (0x834, "load_movie"),
        (0x835, "get_movie_clip"),
        (0x836, "aep_set_set_frame"),
        (0x837, "deep_goto_play_label"),
        (0x838, "deep_goto_stop_label"),
        (0x839, "goto_play_label"),
        (0x83A, "goto_stop_label"),
        (0x83B, "goto_play"),
        (0x83C, "goto_stop"),
        (0x83D, "set_text"),
        (0x83E, "get_text_data"),
        (0x83F, "attach_movie"),
        (0x840, "attach_bitmap"),
        (0x841, "create_movie_clip"),
        (0x842, "set_text_scroll"),
        (0x843, "set_stage"),
        (0x880, "flash.system"),
        (0x881, "flash.display"),
        (0x882, "flash.text"),
        (0x883, "fl.motion"),
        (0x884, "flash.net"),
        (0x885, "flash.ui"),
        (0x886, "flash.geom"),
        (0x887, "flash.filters"),
        (0x888, "flash.events"),
        (0x889, "flash.utils"),
        (0x88A, "flash.media"),
        (0x88B, "flash.external"),
        (0x88C, "flash.errors"),
        (0x88D, "flash.xml"),
        (0x88E, "flash.display3D"),
        (0x88F, "flash.accessibility"),
        (0x890, "flash.display3D.textures"),
        (0x891, "Box2D.Common.Math"),
        (0x892, "Box2D.Collision"),
        (0x893, "Box2D.Collision.Shapes"),
        # Lots of generic function names.
        (0x900, "setDate"),
        (0x901, "setUTCDate"),
        (0x902, "setFullYear"),
        (0x903, "setUTCFullYear"),
        (0x904, "setHours"),
        (0x905, "setUTCHours"),
        (0x906, "setMilliseconds"),
        (0x907, "setUTCMilliseconds"),
        (0x908, "setMinutes"),
        (0x909, "setUTCMinutes"),
        (0x90A, "setMonth"),
        (0x90B, "setUTCMonth"),
        (0x90C, "setSeconds"),
        (0x90D, "setUTCSeconds"),
        (0x90E, "setTime"),
        (0x90F, "setYear"),
        (0x910, "addEventListener"),
        (0x911, "removeEventListener"),
        (0x912, "match"),
        (0x913, "replace"),
        (0x914, "search"),
        (0x915, "append"),
        (0x916, "appendRotation"),
        (0x917, "appendScale"),
        (0x918, "appendTranslation"),
        (0x919, "decompose"),
        (0x91A, "deltaTransformVector"),
        (0x91B, "identity"),
        (0x91C, "interpolateTo"),
        (0x91D, "pointAt"),
        (0x91E, "prepend"),
        (0x91F, "prependRotation"),
        (0x920, "prependScale"),
        (0x921, "prependTranslation"),
        (0x922, "recompose"),
        (0x923, "transformVector"),
        (0x924, "transformVectors"),
        (0x925, "transpose"),
        (0x926, "dispatchEvent"),
        (0x927, "toMatrix3D"),
        (0x928, "appendText"),
        (0x929, "getLineText"),
        (0x92A, "replaceText"),
        (0x92B, "propertyIsEnumerable"),
        (0x92C, "setPropertyIsEnumerable"),
        (0x92D, "drawCircle"),
        (0x92E, "drawEllipse"),
        (0x92F, "drawGraphicsData"),
        (0x930, "drawPath"),
        (0x931, "drawRect"),
        (0x932, "drawRoundRect"),
        (0x933, "drawTriangles"),
        (0x934, "copyFrom"),
        (0x935, "addCallback"),
        (0x936, "overrideTargetTransform"),
        (0x937, "addPropertyArray"),
        (0x938, "getCurrentKeyframe"),
        (0x939, "getMatrix3D"),
        (0x93A, "getColorTransform"),
        (0x93B, "getFilters"),
        (0x93C, "getValue"),
        (0x93D, "hasEventListener"),
        (0x93E, "registerParentFrameHandler"),
        (0x93F, "processCurrentFrame"),
        (0x940, "normalize"),
        (0x941, "elements"),
        (0x942, "toXMLString"),
        (0x943, "attribute"),
        (0x944, "localName"),
        (0x945, "nodeKind"),
        (0x946, "exec"),
        (0x947, "toLocaleString"),
        (0x948, "invalidate"),
        (0x949, "getDefinition"),
        (0x94A, "hasDefinition"),
        (0x94B, "descendants"),
        (0x94C, "loadPolicyFile"),
        (0x94D, "reset"),
        (0x94E, "callProperty"),
        (0x94F, "getProperty"),
        (0x950, "setProperty"),
        (0x951, "willTrigger"),
        (0x952, "send"),
        (0x953, "addTargetInfo"),
        (0x954, "drawRoundRectComplex"),
        (0x955, "forEach"),
        (0x956, "filter"),
        (0x957, "every"),
        (0x958, "some"),
        (0x959, "map"),
        (0x95A, "test"),
        (0x95B, "toDateString"),
        (0x95C, "toLocaleDateString"),
        (0x95D, "toLocaleTimeString"),
        (0x95E, "toTimeString"),
        (0x95F, "toUTCString"),
        (0x960, "parse"),
        (0x961, "project"),
        (0x962, "nearEquals"),
        (0x963, "scaleBy"),
        (0x964, "negate"),
        (0x965, "incrementBy"),
        (0x966, "decrementBy"),
        (0x967, "dotProduct"),
        (0x968, "crossProduct"),
        (0x969, "angleBetween"),
        (0x96A, "decode"),
        (0x96B, "copyColumnFrom"),
        (0x96C, "copyColumnTo"),
        (0x96D, "copyRawDataFrom"),
        (0x96E, "copyRawDataTo"),
        (0x96F, "copyRowFrom"),
        (0x970, "copyRowTo"),
        (0x971, "copyToMatrix3D"),
        (0x972, "requestContext3D"),
        (0x973, "initFilters"),
        (0x974, "addFilterPropertyArray"),
        (0x975, "setTo"),
        (0x976, "createBox"),
        (0x977, "deltaTransformPoint"),
        (0x978, "writeByte"),
        (0x979, "writeInt"),
        (0x97A, "readByte"),
        (0x97B, "writeBoolean"),
        (0x97C, "writeDouble"),
        (0x97D, "readBoolean"),
        (0x97E, "readDouble"),
        (0x97F, "writeUnsignedInt"),
        (0x980, "getVector"),
        (0x981, "setVector"),
        (0x982, "unload"),
        (0x983, "unloadAndStop"),
        (0x984, "toExponential"),
        (0x985, "toFixed"),
        (0x986, "toPrecision"),
        (0x987, "getNewTextFormat"),
        (0x988, "SetV"),
        (0x989, "Set"),
        (0x98A, "SetZero"),
        (0x98B, "Make"),
        (0x98C, "Copy"),
        (0x98D, "Length"),
        (0x98E, "LengthSquared"),
        (0x98F, "Normalize"),
        (0x990, "Multiply"),
        (0x991, "GetNegative"),
        (0x992, "NegativeSelf"),
        (0x993, "Clamp"),
        (0x994, "MulX"),
        (0x995, "Dot"),
        (0x996, "SubtractVV"),
        (0x997, "CrossVF"),
        (0x998, "CrossFV"),
        (0x999, "MulTMV"),
        (0x99A, "CrossVV"),
        (0x99B, "Max"),
        (0x99C, "MulMV"),
        (0x99D, "Abs"),
        (0x99E, "MulXT"),
        (0x99F, "SetM"),
        (0x9A0, "AddM"),
        (0x9A1, "Solve"),
        (0x9A2, "Add"),
        (0x9A3, "Min"),
        (0x9A4, "FromAngle"),
        (0x9A5, "GetTransform"),
        (0x9A6, "Advance"),
        (0x9A7, "GetInverse"),
        (0x9A8, "Combine"),
        (0x9A9, "Contains"),
        (0x9AA, "TestOverlap"),
        (0x9AB, "GetCenter"),
        (0x9AC, "Solve22"),
        (0x9AD, "Solve33"),
        (0x9AE, "SetLocalPosition"),
        (0x9AF, "ComputeAABB"),
        (0x9B0, "ComputeMass"),
        (0x9B1, "GetType"),
        (0x9B2, "SetAsArray"),
        (0x9B3, "GetVertex"),
        (0x9B4, "GetSupport"),
        (0x9B5, "GetSupportVertex"),
        (0x9B6, "GetVertexCount"),
        (0x9B7, "GetVertices"),
        (0x9B8, "ReadCache"),
        (0x9B9, "GetClosestPoint"),
        (0x9BA, "GetSearchDirection"),
        (0x9BB, "Solve2"),
        (0x9BC, "Solve3"),
        (0x9BD, "GetWitnessPoints"),
        (0x9BE, "WriteCache"),
        (0x9BF, "Distance"),
        (0x9C0, "cubicCurveTo"),
        (0x9C1, "wideMoveTo"),
        (0x9C2, "wideLineTo"),
        (0x9C3, "insertAt"),
        (0x9C4, "removeAt"),
        # Seems like more event constants.
        (0xA00, "CLICK"),
        (0xA01, "ENTER_FRAME"),
        (0xA02, "ADDED_TO_STAGE"),
        (0xA03, "MOUSE_DOWN"),
        (0xA04, "MOUSE_MOVE"),
        (0xA05, "MOUSE_OUT"),
        (0xA06, "MOUSE_OVER"),
        (0xA07, "MOUSE_UP"),
        (0xA08, "MOUSE_WHEEL"),
        (0xA09, "ROLL_OUT"),
        (0xA0A, "ROLL_OVER"),
        (0xA0B, "KEY_DOWN"),
        (0xA0C, "KEY_UP"),
        (0xA0D, "TIMER"),
        (0xA0E, "COMPLETE"),
        (0xA0F, "SOUND_COMPLETE"),
        (0xA10, "OPEN"),
        (0xA11, "PROGRESS"),
        (0xA12, "INIT"),
        (0xA13, "IO_ERROR"),
        (0xA14, "TIMER_COMPLETE"),
        (0xA15, "REMOVED_FROM_STAGE"),
        (0xA16, "REMOVED"),
        (0xA17, "FRAME_CONSTRUCTED"),
        (0xA18, "DOUBLE_CLICK"),
        (0xA19, "RESIZE"),
        (0xA1A, "ADDED"),
        (0xA1B, "TAB_CHILDREN_CHANGE"),
        (0xA1C, "TAB_ENABLED_CHANGE"),
        (0xA1D, "TAB_INDEX_CHANGE"),
        (0xA1E, "EXIT_FRAME"),
        (0xA1F, "RENDER"),
        (0xA20, "ACTIVATE"),
        (0xA21, "DEACTIVATE"),
        (0xA22, "SECURITY_ERROR"),
        (0xA23, "ERROR"),
        (0xA24, "CLOSE"),
        (0xA25, "DATA"),
        (0xA26, "CONNECT"),
        (0xA27, "MOUSE_LEAVE"),
        (0xA28, "FOCUS_IN"),
        (0xA29, "FOCUS_OUT"),
        (0xA2A, "KEY_FOCUS_CHANGE"),
        (0xA2B, "MOUSE_FOCUS_CHANGE"),
        (0xA2C, "LINK"),
        (0xA2D, "TEXT_INPUT"),
        (0xA2E, "CHANGE"),
        (0xA2F, "SCROLL"),
        (0xA30, "CONTEXT3D_CREATE"),
        (0xA31, "MENU_ITEM_SELECT"),
        (0xA32, "MENU_SELECT"),
        (0xA33, "UNLOAD"),
        (0xA34, "TOUCH_BEGIN"),
        (0xA35, "TOUCH_END"),
        (0xA36, "TOUCH_MOVE"),
        (0xA37, "TOUCH_OUT"),
        (0xA38, "TOUCH_OVER"),
        (0xA39, "TOUCH_ROLL_OUT"),
        (0xA3A, "TOUCH_ROLL_OVER"),
        (0xA3B, "TOUCH_TAP"),
        (0xA3C, "CONTEXT_MENU"),
        (0xA3D, "MIDDLE_CLICK"),
        (0xA3E, "MIDDLE_MOUSE_DOWN"),
        (0xA3F, "MIDDLE_MOUSE_UP"),
        (0xA40, "RELEASE_OUTSIDE"),
        (0xA41, "RIGHT_CLICK"),
        (0xA42, "RIGHT_MOUSE_DOWN"),
        (0xA43, "RIGHT_MOUSE_UP"),
        # Seems like methods on objects tied to events.
        (0xA80, "click"),
        (0xA81, "enterFrame"),
        (0xA82, "addedToStage"),
        (0xA83, "mouseDown"),
        (0xA84, "mouseMove"),
        (0xA85, "mouseOut"),
        (0xA86, "mouseOver"),
        (0xA87, "mouseUp"),
        (0xA88, "mouseWheel"),
        (0xA89, "rollOut"),
        (0xA8A, "rollOver"),
        (0xA8B, "keyDown"),
        (0xA8C, "keyUp"),
        (0xA8D, "timer"),
        (0xA8E, "complete"),
        (0xA8F, "soundComplete"),
        (0xA90, "open"),
        (0xA91, "progress"),
        (0xA92, "init"),
        (0xA93, "ioError"),
        (0xA94, "timerComplete"),
        (0xA95, "removedFromStage"),
        (0xA96, "removed"),
        (0xA97, "frameConstructed"),
        (0xA98, "doubleClick"),
        (0xA99, "resize"),
        (0xA9A, "added"),
        (0xA9B, "tabChildrenChange"),
        (0xA9C, "tabEnabledChange"),
        (0xA9D, "tabIndexChange"),
        (0xA9E, "exitFrame"),
        (0xA9F, "render"),
        (0xAA0, "activate"),
        (0xAA1, "deactivate"),
        (0xAA2, "securityError"),
        (0xAA3, "error"),
        (0xAA4, "close"),
        (0xAA5, "udf0aa5"),
        (0xAA6, "connect"),
        (0xAA7, "mouseLeave"),
        (0xAA8, "focusIn"),
        (0xAA9, "focusOut"),
        (0xAAA, "keyFocusChange"),
        (0xAAB, "mouseFocusChange"),
        (0xAAC, "link"),
        (0xAAD, "textInput"),
        (0xAAE, "change"),
        (0xAAF, "scroll"),
        (0xAB0, "context3DCreate"),
        (0xAB1, "menuItemSelect"),
        (0xAB2, "menuSelect"),
        (0xAB3, "udf0ab3"),
        (0xAB4, "touchBegin"),
        (0xAB5, "touchEnd"),
        (0xAB6, "touchMove"),
        (0xAB7, "touchOut"),
        (0xAB8, "touchOver"),
        (0xAB9, "touchRollOut"),
        (0xABA, "touchRollOver"),
        (0xABB, "touchTap"),
        (0xABC, "contextMenu"),
        (0xABD, "middleClick"),
        (0xABE, "middleMouseDown"),
        (0xABF, "middleMouseUp"),
        (0xAC0, "releaseOutside"),
        (0xAC1, "rightClick"),
        (0xAC2, "rightMouseDown"),
        (0xAC3, "rightMouseUp"),
        # Seems like debugging information.
        (0xB00, "flash.system.System"),
        (0xB01, "flash.display.Stage"),
        (0xB02, "udf0b02"),
        (0xB03, "sme0b03"),
        (0xB04, "udf0b04"),
        (0xB05, "flash.display.MovieClip"),
        (0xB06, "sme0b06"),
        (0xB07, "flash.text.TextField"),
        (0xB08, "fl.motion.Color"),
        (0xB09, "sme0b09"),
        (0xB0A, "flash.net.SharedObject"),
        (0xB0B, "flash.ui.Mouse"),
        (0xB0C, "sme0b0c"),
        (0xB0D, "flash.media.Sound"),
        (0xB0E, "sme0b0e"),
        (0xB0F, "sme0b0f"),
        (0xB10, "sme0b10"),
        (0xB11, "flash.text.TextFormat"),
        (0xB12, "udf0b12"),
        (0xB13, "udf0b13"),
        (0xB14, "flash.geom.Matrix"),
        (0xB15, "flash.geom.Point"),
        (0xB16, "flash.display.BitmapData"),
        (0xB17, "udf0b17"),
        (0xB18, "udf0b18"),
        (0xB19, "flash.filters.ColorMatrixFilter"),
        (0xB1A, "sme0b1a"),
        (0xB1B, "flash.xml.XMLNode"),
        (0xB1C, "sme0b1c"),
        (0xB1D, "flash.geom.Transform"),
        (0xB1E, "flash.geom.ColorTransform"),
        (0xB1F, "flash.geom.Rectangle"),
        (0xB20, "sme0b20"),
        (0xB21, "sme0b21"),
        (0xB22, "sme0b22"),
        (0xB23, "sme0b23"),
        (0xB24, "udf0b24"),
        (0xB25, "sme0b25"),
        (0xB26, "sme0b26"),
        (0xB27, "sme0b27"),
        (0xB28, "sme0b28"),
        (0xB29, "flash.events.Event"),
        (0xB2A, "flash.events.MouseEvent"),
        (0xB2B, "flash.geom.Matrix3D"),
        (0xB2C, "flash.ui.Keyboard"),
        (0xB2D, "flash.display.DisplayObject"),
        (0xB2E, "flash.utils.Dictionary"),
        (0xB2F, "flash.display.BlendMode"),
        (0xB30, "flash.display.DisplayObjectContainer"),
        (0xB31, "sme0b31"),
        (0xB32, "flash.events.EventDispatcher"),
        (0xB33, "flash.geom.PerspectiveProjection"),
        (0xB34, "flash.geom.Vector3D"),
        (0xB35, "sme0b35"),
        (0xB36, "flash.media.SoundChannel"),
        (0xB37, "flash.display.Loader"),
        (0xB38, "flash.net.URLRequest"),
        (0xB39, "flash.display.Sprite"),
        (0xB3A, "flash.events.KeyboardEvent"),
        (0xB3B, "flash.utils.Timer"),
        (0xB3C, "flash.events.TimerEvent"),
        (0xB3D, "sme0b3d"),
        (0xB3E, "sme0b3e"),
        (0xB3F, "flash.display.LoaderInfo"),
        (0xB40, "flash.events.ProgressEvent"),
        (0xB41, "flash.events.IOErrorEvent"),
        (0xB42, "flash.display.Graphics"),
        (0xB43, "flash.display.LineScaleMode"),
        (0xB44, "flash.display.CapsStyle"),
        (0xB45, "flash.display.JointStyle"),
        (0xB46, "flash.display.GradientType"),
        (0xB47, "flash.display.SpreadMethod"),
        (0xB48, "flash.display.InterpolationMethod"),
        (0xB49, "flash.display.GraphicsPathCommand"),
        (0xB4A, "flash.display.GraphicsPathWinding"),
        (0xB4B, "flash.display.TriangleCulling"),
        (0xB4C, "flash.display.GraphicsBitmapFill"),
        (0xB4D, "flash.display.GraphicsEndFill"),
        (0xB4E, "flash.display.GraphicsGradientFill"),
        (0xB4F, "flash.display.GraphicsPath"),
        (0xB50, "flash.display.GraphicsSolidFill"),
        (0xB51, "flash.display.GraphicsStroke"),
        (0xB52, "flash.display.GraphicsTrianglePath"),
        (0xB53, "flash.display.IGraphicsData"),
        (0xB54, "udf0b54"),
        (0xB55, "flash.external.ExternalInterface"),
        (0xB56, "flash.display.Scene"),
        (0xB57, "flash.display.FrameLabel"),
        (0xB58, "flash.display.Shape"),
        (0xB59, "flash.display.SimpleButton"),
        (0xB5A, "flash.display.Bitmap"),
        (0xB5B, "flash.display.StageQuality"),
        (0xB5C, "flash.display.InteractiveObject"),
        (0xB5D, "fl.motion.MotionBase"),
        (0xB5E, "fl.motion.KeyframeBase"),
        (0xB5F, "sme0b5f"),
        (0xB60, "flash.display.StageAlign"),
        (0xB61, "flash.display.StageScaleMode"),
        (0xB62, "fl.motion.AnimatorBase"),
        (0xB63, "fl.motion.Animator3D"),
        (0xB64, "flash.net.URLLoader"),
        (0xB65, "flash.system.Capabilities"),
        (0xB66, "sme0b66"),
        (0xB67, "sme0b67"),
        (0xB68, "flash.media.SoundTransform"),
        (0xB69, "sme0b69"),
        (0xB6A, "sme0b6a"),
        (0xB6B, "sme0b6b"),
        (0xB6C, "sme0b6c"),
        (0xB6D, "flash.utils.ByteArray"),
        (0xB6E, "flash.text.TextFormatAlign"),
        (0xB6F, "flash.text.TextFieldType"),
        (0xB70, "flash.text.TextFieldAutoSize"),
        (0xB71, "flash.events.SecurityErrorEvent"),
        (0xB72, "flash.system.ApplicationDomain"),
        (0xB73, "flash.events.TextEvent"),
        (0xB74, "flash.events.ErrorEvent"),
        (0xB75, "flash.system.LoaderContext"),
        (0xB76, "sme0b76"),
        (0xB77, "flash.errors.IllegalOperationError"),
        (0xB78, "flash.net.URLLoaderDataFormat"),
        (0xB79, "flash.system.Security"),
        (0xB7A, "flash.filters.DropShadowFilter"),
        (0xB7B, "sme0b7b"),
        (0xB7C, "flash.utils.Proxy"),
        (0xB7D, "flash.net.XMLSocket"),
        (0xB7E, "flash.events.DataEvent"),
        (0xB7F, "flash.text.Font"),
        (0xB80, "flash.events.IEventDispatcher"),
        (0xB81, "flash.net.LocalConnection"),
        (0xB82, "flash.display.ActionScriptVersion"),
        (0xB83, "flash.ui.MouseCursor"),
        (0xB84, "sme0b84"),
        (0xB85, "flash.events.FocusEvent"),
        (0xB86, "flash.text.AntiAliasType"),
        (0xB87, "flash.text.GridFitType"),
        (0xB88, "sme0b88"),
        (0xB89, "flash.filters.BitmapFilterType"),
        (0xB8A, "flash.filters.BevelFilter"),
        (0xB8B, "flash.filters.BitmapFilter"),
        (0xB8C, "flash.filters.BitmapFilterQuality"),
        (0xB8D, "sme0b8d"),
        (0xB8E, "flash.net.URLVariables"),
        (0xB8F, "flash.net.URLRequestMethod"),
        (0xB90, "sme0b90"),
        (0xB91, "flash.filters.BlurFilter"),
        (0xB92, "flash.display.Stage3D"),
        (0xB93, "flash.display3D.Context3D"),
        (0xB94, "flash.ui.Multitouch"),
        (0xB95, "udf0b95"),
        (0xB96, "flash.accessibility.AccessibilityProperties"),
        (0xB97, "flash.text.StaticText"),
        (0xB98, "flash.display.MorphShape"),
        (0xB99, "flash.display.BitmapDataChannel"),
        (0xB9A, "flash.filters.DisplacementMapFilter"),
        (0xB9B, "flash.filters.GlowFilter"),
        (0xB9C, "flash.filters.DisplacementMapFilterMode"),
        (0xB9D, "fl.motion.AnimatorFactoryBase"),
        (0xB9E, "flash.utils.Endian"),
        (0xB9F, "flash.errors.IOError"),
        (0xBA0, "flash.errors.EOFError"),
        (0xBA1, "flash.display3D.Context3DTextureFormat"),
        (0xBA2, "flash.display3D.Context3DProgramType"),
        (0xBA3, "flash.display3D.textures.TextureBase"),
        (0xBA4, "flash.display3D.VertexBuffer3D"),
        (0xBA5, "flash.display3D.IndexBuffer3D"),
        (0xBA6, "flash.display3D.Program3D"),
        (0xBA7, "flash.display.NativeMenuItem"),
        (0xBA8, "flash.ui.ContextMenuItem"),
        (0xBA9, "flash.display.NativeMenu"),
        (0xBAA, "flash.ui.ContextMenu"),
        (0xBAB, "flash.events.ContextMenuEvent"),
        (0xBAC, "flash.display3D.Context3DVertexBufferFormat"),
        (0xBAD, "flash.events.TouchEvent"),
        (0xBAE, "Box2D.Common.Math.b2Vec2"),
        (0xBAF, "Box2D.Common.Math.b2Math"),
        (0xBB0, "Box2D.Common.Math.b2Transform"),
        (0xBB1, "Box2D.Common.Math.b2Mat22"),
        (0xBB2, "Box2D.Common.Math.b2Sweep"),
        (0xBB3, "Box2D.Collision.b2AABB"),
        (0xBB4, "Box2D.Common.Math.b2Vec3"),
        (0xBB5, "Box2D.Common.Math.b2Mat33"),
        (0xBB6, "Box2D.Collision.b2DistanceProxy"),
        (0xBB7, "Box2D.Collision.Shapes.b2Shape"),
        (0xBB8, "Box2D.Collision.Shapes.b2CircleShape"),
        (0xBB9, "Box2D.Collision.Shapes.b2PolygonShape"),
        (0xBBA, "Box2D.Collision.Shapes.b2MassData"),
        (0xBBB, "Box2D.Collision.b2DistanceInput"),
        (0xBBC, "Box2D.Collision.b2DistanceOutput"),
        (0xBBD, "Box2D.Collision.b2SimplexCache"),
        (0xBBE, "Box2D.Collision.b2Simplex"),
        (0xBBF, "Box2D.Collision.b2SimplexVertex"),
        (0xBC0, "Box2D.Collision.b2Distance"),
        (0xBC1, "flash.geom.Orientation3D"),
        (0xBC2, "flash.filters.GradientGlowFilter"),
        (0xBC3, "flash.filters.GradientBevelFilter"),
        # More generic constants.
        (0xC00, "NEARLY_ZERO"),
        (0xC01, "EXACTLY_ZERO"),
        (0xC02, "debug_mode"),
        (0xD00, "m_count"),
        (0xD01, "wA"),
        (0xD02, "wB"),
        (0xD03, "bubbles"),
        (0xD04, "checkPolicyFile"),
        (0xD05, "securityDomain"),
        (0xD06, "spreadMethod"),
        (0xD07, "interpolationMethod"),
        (0xD08, "focalPointRatio"),
        (0xD09, "culling"),
        (0xD0A, "caps"),
        (0xD0B, "winding"),
    ]

    @classmethod
    def property_to_name(cls, propid: int) -> str:
        for i, p in cls.__PROPERTIES:
            if i == propid:
                return p
        return f"<UNKNOWN {hex(propid)}>"

    def __init__(self, const: int, alias: Optional[str] = None) -> None:
        self.const = const
        self.alias = alias

    def __repr__(self) -> str:
        if self.alias:
            return f"StringConstant({hex(self.const)}: {self.alias})"
        else:
            return f"StringConstant({hex(self.const)}: {StringConstant.property_to_name(self.const)})"

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        if self.alias:
            return self.alias
        else:
            return StringConstant.property_to_name(self.const)


class ArithmeticExpression(Expression):
    def __init__(self, left: Any, op: str, right: Any) -> None:
        self.left = left
        self.op = op
        self.right = right

    def __repr__(self) -> str:
        left = value_ref(self.left, "", parens=True)
        right = value_ref(self.right, "", parens=True)
        return f"{left} {self.op} {right}"

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        left = value_ref(self.left, parent_prefix, parens=True)
        right = value_ref(self.right, parent_prefix, parens=True)

        if nested and self.op == "-":
            return f"({left} {self.op} {right})"
        else:
            return f"{left} {self.op} {right}"


class NotExpression(Expression):
    def __init__(self, obj: Any) -> None:
        self.obj = obj

    def __repr__(self) -> str:
        obj = value_ref(self.obj, "", parens=True)
        return f"not {obj}"

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        obj = value_ref(self.obj, parent_prefix, parens=True)
        return f"not {obj}"


class Array(Expression):
    # Call a method on an object.
    def __init__(self, params: List[Any]) -> None:
        self.params = params

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        params = [value_ref(param, parent_prefix) for param in self.params]
        return f"[{', '.join(params)}]"


class Object(Expression):
    # Call a method on an object.
    def __init__(self, params: Dict[Any, Any]) -> None:
        self.params = params

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        params = [
            f"{value_ref(key, parent_prefix)}: {value_ref(val, parent_prefix)}" for (key, val) in self.params.items()
        ]
        lpar = "{"
        rpar = "}"

        return f"{lpar}{', '.join(params)}{rpar}"


class FunctionCall(Expression):
    # Call a method on an object.
    def __init__(self, insertion_ref: int, name: Union[str, StringConstant], params: List[Any]) -> None:
        self.insertion_ref = insertion_ref
        self.name = name
        self.params = params

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        name = name_ref(self.name, parent_prefix)
        params = [value_ref(param, parent_prefix) for param in self.params]
        return f"{name}({', '.join(params)})"


class GetTimeFunctionCall(FunctionCall):
    # Call the built-in 'get time' method which returns the current playback position.
    def __init__(self, insertion_ref: int) -> None:
        super().__init__(insertion_ref, "builtin_GetCurrentPlaybackPosition", [])


class GetPathFunctionCall(FunctionCall):
    # Call the built-in 'get time' method which returns the current playback position.
    def __init__(self, insertion_ref: int, movieclip: Any) -> None:
        super().__init__(insertion_ref, "builtin_GetPathOfMovie", [movieclip])


class MethodCall(Expression):
    # Call a method on an object.
    def __init__(
        self,
        insertion_ref: int,
        objectref: Any,
        name: Union[str, int, Expression],
        params: List[Any],
    ) -> None:
        self.insertion_ref = insertion_ref
        self.objectref = objectref
        self.name = name
        self.params = params

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        try:
            obj = object_ref(self.objectref, parent_prefix)
            name = name_ref(self.name, parent_prefix)
            params = [value_ref(param, parent_prefix) for param in self.params]
            return f"{obj}.{name}({', '.join(params)})"
        except Exception:
            obj = object_ref(self.objectref, parent_prefix)
            name = value_ref(self.name, parent_prefix)
            params = [value_ref(param, parent_prefix) for param in self.params]
            return f"{obj}[{name}]({', '.join(params)})"


class NewFunction(Expression):
    # Create a new function.
    def __init__(self, flags: int, body: "ByteCodeDecompiler") -> None:
        self.flags = flags
        self.body = body

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        code = self.body.as_string(prefix=parent_prefix + "    ")
        opar = "{"
        cpar = "}"
        val = f"new Function({hex(self.flags)}, {opar}{os.linesep}{code}{os.linesep}{parent_prefix}{cpar})"
        if nested:
            return f"({val})"
        else:
            return val


class NewObject(Expression):
    # Create a new object of type.
    def __init__(self, objname: Union[str, StringConstant], params: List[Any]) -> None:
        self.objname = objname
        self.params = params

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        objname = name_ref(self.objname, parent_prefix)
        params = [value_ref(param, parent_prefix) for param in self.params]
        val = f"new {objname}({', '.join(params)})"
        if nested:
            return f"({val})"
        else:
            return val


class Variable(Expression):
    def __init__(self, name: Union[str, StringConstant]) -> None:
        self.name = name

    def __repr__(self) -> str:
        return f"Variable({name_ref(self.name, '')})"

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        return name_ref(self.name, parent_prefix)


class Member(Expression):
    # A member can be an array entry in an array, or an object member as accessed
    # in array lookup syntax or dot notation.
    def __init__(self, objectref: Any, member: Union[str, int, Expression]) -> None:
        self.objectref = objectref
        self.member = member

    def __repr__(self) -> str:
        return self.render("")

    def render(self, parent_prefix: str, nested: bool = False) -> str:
        try:
            member = name_ref(self.member, parent_prefix)
            ref = object_ref(self.objectref, parent_prefix)
            return f"{ref}.{member}"
        except Exception:
            # This is not a simple string object reference.
            member = value_ref(self.member, parent_prefix)
            ref = object_ref(self.objectref, parent_prefix)
            return f"{ref}[{member}]"


# The following are helpers which facilitate rendering out various parts of expressions.
def object_ref(obj: Any, parent_prefix: str) -> str:
    if isinstance(obj, (GenericObject, Variable, Member, MethodCall, FunctionCall, Register)):
        return obj.render(parent_prefix, nested=True)
    else:
        raise Exception(f"Unsupported objectref {obj} ({type(obj)})")


def value_ref(param: Any, parent_prefix: str, parens: bool = False) -> str:
    if isinstance(param, StringConstant):
        # Treat this as a string constant.
        return repr(param.render(parent_prefix))
    elif isinstance(param, Expression):
        return param.render(parent_prefix, nested=parens)
    elif isinstance(param, (str, int, float, bool)):
        return repr(param)
    else:
        raise Exception(f"Unsupported valueref {param} ({type(param)})")


def name_ref(param: Any, parent_prefix: str) -> str:
    # Reference a name, so strings should not be quoted.
    if isinstance(param, str):
        return param
    elif isinstance(param, StringConstant):
        return param.render(parent_prefix)
    else:
        raise Exception(f"Unsupported nameref {param} ({type(param)})")
