### Install SWF Parser for Node.js and Rust Source: https://context7.com/open-flash/swf-parser/llms.txt Provides installation instructions for the SWF Parser library using npm/yarn for TypeScript/Node.js environments and Cargo for Rust projects. ```bash # TypeScript/Node.js npm install swf-parser # or yarn add swf-parser # Rust - Add to Cargo.toml # [dependencies] # swf-parser = "0.14" ``` -------------------------------- ### Install Dependencies and Run Tests for SWF Parser (Yarn) Source: https://github.com/open-flash/swf-parser/blob/main/ts/README.md This section outlines the steps to set up the development environment for the SWF Parser. It involves navigating to the 'ts' directory, installing dependencies using Yarn, and running tests. Yarn is recommended for dependency management. ```sh cd ts yarn install # work your changes... yarn test ``` -------------------------------- ### GetTime Action (0x34) Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/get-time.md Retrieves the number of milliseconds since the Adobe Flash Player started and pushes it onto the stack. ```APIDOC ## GET /open-flash/swf-parser/getTime ### Description This endpoint represents the GetTime action (0x34) within the SWF format. It calculates and returns the number of milliseconds that have elapsed since the Flash Player was initialized. This value is then pushed onto the stack for further processing. ### Method GET ### Endpoint /open-flash/swf-parser/getTime ### Parameters #### Query Parameters None #### Request Body None ### Request Example (Not Applicable for this action) ### Response #### Success Response (200) - **elapsedTime** (integer) - The number of milliseconds since the Flash Player started. #### Response Example { "elapsedTime": 12345 } ``` -------------------------------- ### Fuzz SWF Parser with cargo-fuzz (Shell) Source: https://github.com/open-flash/swf-parser/blob/main/rs/README.md Illustrates how to set up and run fuzz tests for the SWF parser using the `cargo-fuzz` tool. It first ensures `cargo-fuzz` is installed and then executes the fuzzing command for the 'swf' target. ```sh # Make sure that you have `cargo-fuzz` cargo install cargo-fuzz # Fuzz the `swf` parser cargo fuzz run swf ``` -------------------------------- ### ActionInitObject Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/init-object.md Initializes a new object by popping property names and values from the stack. ```APIDOC ## ActionInitObject ### Description Initializes an object and pushes it onto the stack. This action is similar to ActionInitArray. The newly created object can be stored in a variable using a subsequent SetVariable or SetMember action. ### Method N/A (Opcode-based instruction) ### Endpoint N/A (Opcode-based instruction) ### Parameters #### Stack Operations - Pops `elems` (where `elems` is `[value1, name1, ..., valueN, nameN]`) from the stack. - Pops the number of initial properties (`itemCount`) from the stack. #### Action Properties - **ActionCode**: `0x43` - **Stack Transformation**: `2k + 1 → 1` (where `k` is the number of properties) - **SWF Version**: `5` ### Process 1. Pops the number of initial properties (`itemCount`) from the stack. 2. Initializes the object as a `ScriptObject`. 3. Sets the object type to `Object`. 4. For each initial property (from `itemCount` down to 1): a. Pops the value of the property from the stack. b. Pops the name of the property from the stack. c. Converts the property name to a string. d. Assigns the value to the property name on the newly created object. ### Request Example ``` [...(value, name), itemCount] ``` ### Response #### Success Response - The newly created `ScriptObject` is pushed onto the stack. ``` -------------------------------- ### ActionAnd Operation Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/and.md Explains the ActionAnd operation, its stack manipulation, and logic for different SWF versions. ```APIDOC ## ActionAnd Operation ### Description Performs a logical AND of two numbers. It's important to note a typo in the official documentation where 'ActionAdd' was mistakenly used instead of 'ActionAnd'. ### Method N/A (This is an action code within SWF) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` [b, a] -> [b && a] ``` ### Response #### Success Response (Stack Effect) - **Result** (Boolean/Number) - The result of the logical AND operation is pushed onto the stack. For SWF 4, 0 is pushed for false and 1 for true. For SWF 5 and later, false or true is pushed. #### Response Example For SWF 4: ```json { "result": 1 } ``` For SWF 5+: ```json { "result": true } ``` ### Notes - **Action Code**: `0x10` - **Stack Effect**: `2 -> 1` (Pops two values, pushes one) - **SWF Version Compatibility**: Affects the pushed value representation (0/1 for SWF 4, false/true for SWF 5+). - **Type Conversion**: Non-numeric values are converted to 0 before the AND operation. ``` -------------------------------- ### SWF Compression Handling in Rust and TypeScript Source: https://context7.com/open-flash/swf-parser/llms.txt Demonstrates how the SWF parser handles different compression methods automatically. The Rust implementation uses Cargo feature flags for specific compression algorithms like 'deflate' and 'lzma', while the TypeScript version relies on the 'pako' library. Error handling for unsupported or unknown compression methods is also shown. ```rust // Rust Cargo.toml configuration // [dependencies] // swf-parser = { version = "0.14", features = ["deflate", "lzma"] } // Or disable compression for smaller binary size: // swf-parser = { version = "0.14", default-features = false } use swf_parser::{parse_swf, SwfParseError}; fn parse_with_error_handling(bytes: &[u8]) { match parse_swf(bytes) { Ok(movie) => { println!("Successfully parsed {} tags", movie.tags.len()); } Err(SwfParseError::InvalidSignature) => { eprintln!("Not a valid SWF file (bad magic bytes)"); } Err(SwfParseError::UnsupportedCompression(method)) => { eprintln!("Compression method {:?} not supported", method); eprintln!("Enable the corresponding Cargo feature"); } Err(SwfParseError::InvalidPayload) => { eprintln!("Failed to decompress SWF payload"); } Err(SwfParseError::InvalidHeader) => { eprintln!("Invalid movie header after decompression"); } } } ``` ```typescript // TypeScript - Compression is handled automatically via pako import { parseSwf } from "swf-parser"; try { const movie = parseSwf(swfBytes); console.log("Parsed successfully"); } catch (error) { if (error.name === "NotImplemented") { console.error("LZMA compression not yet supported in TypeScript"); } else if (error.name === "UnknownCompressionMethod") { console.error("Unknown compression method in SWF signature"); } } ``` -------------------------------- ### Parse SWF File Bytes to Movie Object (TypeScript) Source: https://github.com/open-flash/swf-parser/blob/main/ts/README.md This snippet demonstrates how to parse SWF file bytes into a 'Movie' object using the 'swf-parser' library. It reads SWF data from a file and then converts it into a structured movie representation. Ensure 'swf-types' is installed as a dependency. ```typescript import fs from "fs"; import { Movie } from "swf-types"; import { parseSwf } from "swf-parser"; const bytes: Uint8Array = fs.readFileSync("movie.swf"); const movie: Movie = parseSwf(bytes); ``` -------------------------------- ### ActionCallMethod Stack Operation (AS2) Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/call-method.md Illustrates the stack manipulation for ActionCallMethod, showing the sequence of arguments, count, method name, object, and the resulting return value. This operation is crucial for understanding method invocation within SWF. ```as2 [...arguments, argsCount, methodName, object] → [returnValue] ``` -------------------------------- ### ActionNewObject Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/new-object.md The ActionNewObject action is used to invoke a constructor function, creating a new object. It manages the stack by popping arguments and the object name, then pushing the newly constructed object. ```APIDOC ## ActionNewObject ### Description Invokes a constructor function to create a new object. The newly created object is passed as the `this` keyword to the constructor, and optional arguments can be provided. The return value of the constructor is discarded, and the newly constructed object is pushed onto the stack. ### Method N/A (Internal Action Code) ### Endpoint N/A ### Parameters #### Stack Operations - **Pops**: object name (STRING), numArgs (INT), arguments - **Pushes**: newObject (OBJECT) ### Request Example ``` [...args, argsCount, objectName] ``` ### Response #### Success Response - **newObject** (OBJECT) - The newly constructed object pushed onto the stack. #### Response Example ``` [newObject] ``` ### Notes - Action Code: `0x40` - SWF Version: `5` - Similar to `ActionCallFunction` and `ActionNewMethod`. - Arguments are pushed onto the stack in reverse order. ``` -------------------------------- ### ActionStringEquals Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/string-equals.md Compares two strings popped from the stack for equality. The result (true/false or 1/0) is pushed back onto the stack. ```APIDOC ## ActionStringEquals ### Description Compares two strings popped from the stack for equality. The result (true/false or 1/0) is pushed back onto the stack. ### Method Stack Operation ### Endpoint N/A (Internal Action Code) ### Parameters #### Stack Parameters - **A** (String) - Popped first. The second string to compare. - **B** (String) - Popped second. The first string to compare. ### Request Example ``` [b, a] ``` ### Response #### Success Response - **Result** (Boolean/Number) - `true` (or `1` for SWF 4) if strings are equal, `false` (or `0` for SWF 4) otherwise. #### Response Example ```json { "result": "true" } ``` ### Details - **Action Code**: `0x13` - **Stack Change**: `2 -> 1` - **SWF Version**: Applicable from SWF 4 onwards. Behavior differs slightly for SWF 4 (pushes 1/0) vs. SWF 5+ (pushes true/false). - **Comparison Type**: Case-sensitive string comparison. ``` -------------------------------- ### ActionGotoFrame2 Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/goto-frame2.md The ActionGotoFrame2 action allows navigation to a specific frame within a movie clip, with options to play or stop playback. It operates on a stack-based system for frame identification. ```APIDOC ## ActionGotoFrame2 ### Description Navigates to a specified frame within the current movie clip. This action is stack-based, meaning it retrieves frame information from the execution stack. It supports both frame numbers and frame labels for navigation and includes a flag to control playback after navigation. ### Method Not Applicable (This is a SWF action code, not an HTTP endpoint) ### Endpoint Not Applicable ### Parameters #### Action Record Header - **ActionCode** (UB[8]) - `0x9f` - Identifies the ActionGotoFrame2 action. #### Frame Navigation and Control - **Reserved** (UB[6]) - `0` - Reserved bits, always zero. - **SceneBiasFlag** (UB[1]) - Flag indicating if SceneBias is present. - **Play flag** (UB[1]) - Controls playback: `0` for stop, `1` for play. - **SceneBias** (UI16, conditional) - If SceneBiasFlag is `1`, this UI16 value is added to the frame determined by the stack argument. #### Stack Operations - Pops a frame from the stack. This frame can be: - A number: `n` - Navigates to the nth frame. - A string: `frame label` - Navigates to the frame with the specified label. If the label is not found, the action is ignored. - A target path prefix (e.g., `/MovieClip:3` or `/MovieClip:FrameLabel`) can prefix the frame or label. ### Request Example Not Applicable (This is a SWF action, not a request body) ### Response #### Success Response Navigation to the specified frame occurs. Playback continues or stops based on the 'Play flag'. #### Response Example Not Applicable (This is a SWF action, not a response body) ``` -------------------------------- ### ActionCallMethod Functionality (AS2) Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/call-method.md Demonstrates how ActionCallMethod executes method calls based on the provided object and method name. It covers scenarios where the method name is blank (direct function invocation) and when a specific method is called on an object. ```as2 obj(); obj.foo(); ``` -------------------------------- ### ActionGetProperty Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/get-property.md Retrieves a property from a target object based on an index. This action is used to access various properties of movie clips. ```APIDOC ## ActionGetProperty ### Description Retrieves the value of a specified property from a target movie clip and pushes it onto the stack. ### Method N/A (Internal ActionScript Opcode) ### Endpoint N/A ### Parameters #### Stack Operations - Pops `index` (Number) from the stack. - Pops `target` (Object) from the stack. ### Action Details - Action Code: `0x22` - Stack Effect: `2 → 1` (Pops 2 items, pushes 1 item) - SWF Version: `4` and later ### Property Index Values | Property | Value | Notes | |---------------|-------|-------| | `_X` | 0 | | | `_Y` | 1 | | | `_xscale` | 2 | | | `_yscale` | 3 | | | `_currentframe` | 4 | | | `_totalframes`| 5 | | | `_alpha` | 6 | | | `_visible` | 7 | | | `_width` | 8 | | | `_height` | 9 | | | `_rotation` | 10 | | | `_target` | 11 | | | `_framesloaded`| 12 | | | `_name` | 13 | | | `_droptarget` | 14 | | | `_url` | 15 | | | `_highquality`| 16 | | | `_focusrect` | 17 | | | `_soundbuftime`| 18 | | | `_quality` | 19 | SWF 5+ | | `_xmouse` | 20 | SWF 5+ | | `_ymouse` | 21 | SWF 5+ | ### Result - Pushes the retrieved property value onto the stack. ``` -------------------------------- ### ActionDivide Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/divide.md The ActionDivide action pops two values from the stack, divides the second by the first, and pushes the result back onto the stack. It handles type conversion and division by zero according to SWF version specifications. ```APIDOC ## ActionDivide ### Description Performs division of two numbers popped from the stack. The second popped number is divided by the first popped number. ### Method N/A (ActionScript bytecode instruction) ### Endpoint N/A ### Parameters #### Stack Parameters - **arg1** (Number) - Value to be used as the divisor. - **arg2** (Number) - Value to be used as the dividend. ### Request Example (Illustrative stack operation) ``` [arg2, arg1] → [arg2 / arg1] ``` ### Response #### Stack Response - **result** (Number) - The result of arg2 divided by arg1. For SWF 5+, this can be NaN, Infinity, or -Infinity if arg1 is zero. For SWF 4, it results in the string #ERROR# if arg1 is zero. ### Notes - Action Code: `0x0c` - Stack Transformation: `2 → 1` - SWF Version: `4+` (behavior for division by zero differs in SWF 4 vs SWF 5+) ``` -------------------------------- ### ActionDefineFunction Structure and Usage (ActionScript 2) Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/define-function.md Demonstrates the structure and two primary usage patterns of ActionDefineFunction in ActionScript 2. It covers defining anonymous functions and named functions. ```actionscript area = (function () {return Math.PI * radius * radius;})(5); function Circle(radius) { this.radius = radius; this.area = Math.PI * radius * radius; } ``` -------------------------------- ### ActionStringLess Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/string-less.md Compares two strings lexicographically and pushes a boolean result (true/false or 1/0) onto the stack based on the comparison. ```APIDOC ## ActionStringLess ### Description Compares two strings lexicographically and pushes a boolean result onto the stack. For SWF 5 and later, it pushes `true` or `false`. For SWF 4, it pushes `1` or `0`. ### Method N/A (This is an action code within the SWF format, not a standard HTTP API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body This action operates on the stack. It expects two string values to be present on the stack. - **A** (string) - The second string popped from the stack. - **B** (string) - The first string popped from the stack. ### Request Example (Illustrative stack state before operation) ``` Stack: ["stringB", "stringA"] ``` ### Response #### Success Response - **Result** (boolean or integer) - `true` (or `1`) if `B < A`, `false` (or `0`) otherwise. #### Response Example (Illustrative stack state after operation, assuming B < A and SWF version 5+) ``` Stack: [true] ``` (Illustrative stack state after operation, assuming B < A and SWF version 4) ``` Stack: [1] ``` ### Action Code `0x29` ### Stack Transformation `2 → 1` ### SWF Version Compatibility - SWF 4: Pushes `1` for true, `0` for false. - SWF 5 and later: Pushes `true` for true, `false` for false. ``` -------------------------------- ### ActionWaitForFrame2 Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/wait-for-frame2.md The ActionWaitForFrame2 opcode waits for a specified frame to be loaded. It is a stack-based action that can conditionally skip subsequent actions based on the frame's loaded status. ```APIDOC ## ActionWaitForFrame2 ### Description ActionWaitForFrame2 waits for a frame to be loaded and is stack based. It pops a frame off the stack, and if the frame is loaded, it skips the next n actions where n is indicated by SkipCount. The frame evaluation is similar to ActionGotoFrame2. ### Method Not Applicable (Opcode) ### Endpoint Not Applicable (Opcode) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ### Opcode Details - **Action Code**: `0x82` (Note: The original documentation mentions `0x8D`, but the provided header indicates `0x82` is the correct code for this context within the parser.) - **Stack**: `1 → 0` (Pops one item, pushes zero items) - **SWF Version**: `4` ### Structure | Field | Type | Comment | |--------------|------|---------------------------------------| | ActionHeader | UI8 | ActionCode = 0x82 | | SkipCount | UI8 | The number of actions to skip | ``` -------------------------------- ### ActionCharToAscii Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/char-to-ascii.md Converts a character code to its corresponding ASCII value. This action pops a value from the stack, converts its first character to an ASCII code, and pushes the result back onto the stack. ```APIDOC ## POST /open-flash/swf-parser/CharToAscii ### Description Converts a character code to its corresponding ASCII value. This action pops a value from the stack, converts its first character to an ASCII code, and pushes the result back onto the stack. ### Method POST ### Endpoint /open-flash/swf-parser/CharToAscii ### Parameters #### Query Parameters - **ActionCode** (hex) - Required - ActionCode = 0x32 #### Request Body This endpoint does not expect a request body, as operations are performed on the stack. ### Response #### Success Response (200) - **Stack** (integer) - The resulting ASCII character code pushed onto the stack. #### Response Example ```json { "stack_operation": "1 -> 1" } ``` ``` -------------------------------- ### ActionStringAdd Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/string-add.md Concatenates two strings by popping them from the stack and pushing the result back. ```APIDOC ## ActionStringAdd ### Description ActionStringAdd concatenates two strings. It pops two string values from the stack, concatenates them (second popped string followed by the first popped string), and pushes the resulting string back onto the stack. ### Method N/A (This is an action code within the SWF format, not a typical HTTP API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` [b, a] → [String(b) + String(a)] ``` ### Response #### Success Response (Stack Effect) - **Result** (string) - The concatenated string pushed onto the stack. #### Response Example ``` "HelloWorld" ``` ### Additional Information - **Action Code**: `0x21` - **Stack Effect**: `2 → 1` (Pops 2 items, pushes 1 item) - **SWF Version**: `4` ``` -------------------------------- ### ActionDefineFunction2 Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/define-function2.md Defines a function with advanced features for performance optimization, including register allocation and variable preloading/suppression. ```APIDOC ## ActionDefineFunction2 ### Description ActionDefineFunction2 is an advanced action that allows for optimized function execution by managing registers and controlling variable scope. It offers performance benefits by reducing the creation of unused variables and enabling direct register manipulation for parameters and local variables. ### Method N/A (This is a data structure within SWF files) ### Endpoint N/A ### Parameters #### Header - **ActionDefineFunction2** (ACTIONRECORDHEADER) - ActionCode = 0x8E #### Fields - **FunctionName** (STRING) - The name of the function. If empty, the function is anonymous. - **NumParams** (UI16) - The number of parameters the function accepts. - **RegisterCount** (UI8) - The number of registers to allocate for the function's local scope (0 to 254). #### Flags (Each is a UB[1]) - **PreloadParentFlag**: 1 to preload `_parent` into a register, 0 otherwise. - **PreloadRootFlag**: 1 to preload `_root` into a register, 0 otherwise. - **SuppressSuperFlag**: 1 to suppress the creation of the `super` variable, 0 otherwise. - **PreloadSuperFlag**: 1 to preload `super` into a register, 0 otherwise. - **SuppressArgumentsFlag**: 1 to suppress the creation of the `arguments` variable, 0 otherwise. - **PreloadArgumentsFlag**: 1 to preload `arguments` into a register, 0 otherwise. - **SuppressThisFlag**: 1 to suppress the creation of the `this` variable, 0 otherwise. - **PreloadThisFlag**: 1 to preload `this` into a register, 0 otherwise. - **Reserved** (UB[7]) - Reserved for future use, should always be 0. - **PreloadGlobalFlag**: 1 to preload `_global` into a register, 0 otherwise. *Note: Specifying both a preload and suppress flag for the same variable is not allowed.* - **Parameters** (REGISTERPARAM[NumParams]) - An array defining how each parameter is handled. See REGISTERPARAM definition below. - **codeSize** (UI16) - The size in bytes of the function's code that follows. ### REGISTERPARAM Definition - **Register** (UI8) - If 0, the parameter is created as a variable in the activation object. If non-zero, the parameter is copied into the specified register. - **ParamName** (STRING) - The name of the parameter. ### Request Example (This is a binary structure, not typically represented as a JSON request body) ### Response #### Success Response (200) N/A (This defines a function within SWF data) #### Response Example (N/A) ``` -------------------------------- ### ActionStringExtract (0x15) Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/string-extract.md The ActionStringExtract action extracts a substring from a given string based on an index and a count. It manipulates the stack by popping values and pushing the resulting substring. ```APIDOC ## ActionStringExtract (0x15) ### Description Extracts a substring from a string. It pops a count, an index, and the string itself from the stack, then pushes the resulting substring back onto the stack. ### Method Stack Operation ### Endpoint N/A (Internal SWF Action) ### Parameters #### Stack Parameters - **count** (number) - Pops the number of characters to extract. - **index** (number) - Pops the starting index for the extraction. - **string** (string) - Pops the string from which to extract the substring. ### Request Example ``` [string, index, count] ``` ### Response #### Success Response - **Substring** (string) - The extracted substring is pushed onto the stack. #### Response Example ``` [Substring] ``` ### Notes - If `index` or `count` do not evaluate to integers, an empty string is returned. - Action Code: `0x15` - Stack Transformation: `3 → 1` - Requires SWF Version: `4` ``` -------------------------------- ### ActionGetVariable Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/get-variable.md Retrieves the value of a specified variable from the stack. ```APIDOC ## POST /open-flash/swf-parser/ActionGetVariable ### Description Retrieves a variable's value by popping its name from the stack and pushing the value onto the stack. Supports referencing variables in other execution contexts using a target path. ### Method POST ### Endpoint /open-flash/swf-parser/ActionGetVariable ### Parameters #### Request Body - **name** (string) - Required - The name of the variable to retrieve. ### Request Example ```json { "name": "myVariable" } ``` ### Response #### Success Response (200) - **eval(name)** (any) - The value of the retrieved variable. #### Response Example ```json { "eval(name)": "variableValue" } ``` ### Notes - Action Code: `0x1c` - Stack: `1 → 1` - SWF version: `4` - To reference a variable in another execution context, prefix the variable name with the target path and a colon (e.g., `/A/B:FOO`). ``` -------------------------------- ### ActionNot Operation Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/not.md Details the ActionNot operation, including its action code, stack transformation, and behavior based on SWF version. ```APIDOC ## ActionNot Operation ### Description Performs a logical NOT operation on a value from the stack. The behavior differs slightly between SWF 4 and SWF 5+ regarding type conversion and result values. ### Method N/A (This is an internal action code, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Stack Operations - Pops a value off the stack. - Converts the value to floating point; non-numeric values evaluate to 0. ### Behavior - **SWF 5 and later**: If the value is zero, `true` is pushed. If the value is non-zero, `false` is pushed. The result is a Boolean. - **SWF 4**: If the value is zero, `1` is pushed. If the value is non-zero, `0` is pushed. The result is a number. ### Action Code `0x12` ### Stack Transformation `1 → 1` ### SWF Version Compatibility - SWF 4 - SWF 5+ ``` -------------------------------- ### Clone and Update Git Submodules for SWF Parser Project Source: https://github.com/open-flash/swf-parser/blob/main/ts/README.md These commands are used to manage Git submodules for the SWF Parser project. The first command clones the repository along with its submodules, while the second updates existing submodules. This is necessary for accessing test samples included as submodules. ```sh # Clone with submodules git clone --recurse-submodules git://github.com/open-flash/swf-parser.git # Update submodules for an already-cloned repo git submodule update --init --recursive --remote ``` -------------------------------- ### ActionExtends Implementation (ActionScript 2.0) Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/extends.md This snippet demonstrates the ActionScript 2.0 code that ActionExtends emulates. It sets up the prototype chain for inheritance, assigning a new object as the subclass's prototype and linking it to the superclass's prototype. ```actionscript Subclass.prototype = new Object(); Subclass.prototype. proto = Superclass.prototype; Subclass.prototype. constructor = Superclass; ``` -------------------------------- ### ActionDecrement Source: https://github.com/open-flash/swf-parser/blob/main/docs/avm1/actions/decrement.md The ActionDecrement operation pops a value from the stack, converts it to a number, decrements it by 1, and pushes the result back onto the stack. ```APIDOC ## POST /open-flash/swf-parser/decrement ### Description Decrements a value popped from the stack by 1 and pushes the result back onto the stack. The value is converted to a number before decrementing. ### Method POST ### Endpoint /open-flash/swf-parser/decrement ### Parameters #### Query Parameters - **value** (string) - Required - The value to be decremented. ### Request Example ```json { "value": "10" } ``` ### Response #### Success Response (200) - **result** (number) - The decremented value. #### Response Example ```json { "result": 9 } ``` ```