### Browser Extension Installation Source: https://context7.com/ruffle-rs/ruffle/llms.txt Guide on how to install the Ruffle browser extension, either from official stores or by manual loading. ```APIDOC ## Browser Extension Installation Install the Ruffle browser extension from official stores or manually load from source. ### Official Stores Download the extension directly from your browser's web store. ```bash # Download from official sources: # Chrome: https://chrome.google.com/webstore/detail/ruffle/donbcfbmhbcapadipfkeojnmajbakjdc # Firefox: https://addons.mozilla.org/firefox/addon/ruffle_rs/ # Firefox Android: https://addons.mozilla.org/en/android/addon/ruffle_rs/ ``` ### Manual Installation (Chrome/Chromium) For Chrome and Chromium-based browsers, you can install the extension by loading a ZIP file. ```bash # 1. Download web-extension.zip from https://github.com/ruffle-rs/ruffle/releases # 2. Navigate to chrome://extensions/ # 3. Enable "Developer mode" # 4. Drag and drop the ZIP file onto the extensions page ``` ### Development Installation (Chrome) Install the extension during development by loading it directly from the build output. ```bash cd web npm install && npm run build # Navigate to chrome://extensions/ # Enable "Developer mode" # Click "Load unpacked" and select web/packages/extension/assets/ ``` ### Safari Installation (macOS) Install Ruffle on macOS for Safari by downloading and enabling the extension. ```bash # 1. Download macos-universal.tar.gz from releases # 2. Extract and open the app # 3. Enable: Safari > Preferences > Advanced > Show Develop menu # 4. Enable: Develop > Allow Unsigned Extensions # 5. Check the extension in Safari > Preferences > Extensions ``` ``` -------------------------------- ### Get Ruffle Help (Linux Flatpak) Source: https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle Display command-line options for Ruffle when installed via Flatpak on Linux. ```bash flatpak run rs.ruffle.Ruffle --help ``` -------------------------------- ### Control Flow and Navigation Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/swf4_actions_coercion_order/output.txt Examples of calling methods, getting URLs, navigating frames, and setting targets. ```actionscript obj_2.toString() ``` ```actionscript obj_2.toString()\nobj_1.toString() ``` ```actionscript obj_2.toString() ``` ```actionscript obj_2.toString()\nTarget not found: Target="[type Object]" Base="_level0"\ntellTarget ``` ```actionscript obj_1.toString()\nifFrameLoaded ``` -------------------------------- ### Get Ruffle Help (Linux Non-Flatpak) Source: https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle Display command-line options for Ruffle when installed directly on Linux (non-Flatpak). ```bash ./ruffle --help ``` -------------------------------- ### Object Initialization Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/class_call/output.txt Shows how to initialize Object types. ```actionscript Object() [object Object] ``` ```actionscript Object("asdf") asdf ``` -------------------------------- ### Get UTC Day from Specific Dates Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/ecma3/Date/e15_9_5_11_4/output.txt These examples demonstrate retrieving the UTC day from various specific historical dates using JavaScript's Date object and the getUTCDate() method. No specific setup is required beyond standard JavaScript execution. ```javascript (new Date(-2206310400000)).getUTCDate() ``` ```javascript (new Date(-2205705600000)).getUTCDate() ``` ```javascript (new Date(-2204496000000)).getUTCDate() ``` ```javascript (new Date(-2202681600000)).getUTCDate() ``` ```javascript (new Date(-2200262400000)).getUTCDate() ``` ```javascript (new Date(-2197756800000)).getUTCDate() ``` ```javascript (new Date(-2197152000000)).getUTCDate() ``` ```javascript (new Date(-2195942400000)).getUTCDate() ``` ```javascript (new Date(-2194128000000)).getUTCDate() ``` ```javascript (new Date(-2191708800000)).getUTCDate() ``` ```javascript (new Date(-2189030400000)).getUTCDate() ``` ```javascript (new Date(-2188425600000)).getUTCDate() ``` ```javascript (new Date(-2187216000000)).getUTCDate() ``` ```javascript (new Date(-2185401600000)).getUTCDate() ``` ```javascript (new Date(-2182982400000)).getUTCDate() ``` ```javascript (new Date(-2180390400000)).getUTCDate() ``` ```javascript (new Date(-2179785600000)).getUTCDate() ``` ```javascript (new Date(-2178576000000)).getUTCDate() ``` ```javascript (new Date(-2176761600000)).getUTCDate() ``` ```javascript (new Date(-2174342400000)).getUTCDate() ``` ```javascript (new Date(-2171664000000)).getUTCDate() ``` ```javascript (new Date(-2171059200000)).getUTCDate() ``` ```javascript (new Date(-2169849600000)).getUTCDate() ``` ```javascript (new Date(-2168035200000)).getUTCDate() ``` ```javascript (new Date(-2165616000000)).getUTCDate() ``` ```javascript (new Date(-2163024000000)).getUTCDate() ``` ```javascript (new Date(-2162419200000)).getUTCDate() ``` ```javascript (new Date(-2161209600000)).getUTCDate() ``` ```javascript (new Date(-2159395200000)).getUTCDate() ``` ```javascript (new Date(-2156976000000)).getUTCDate() ``` ```javascript (new Date(-2154297600000)).getUTCDate() ``` ```javascript (new Date(-2153692800000)).getUTCDate() ``` ```javascript (new Date(-2152483200000)).getUTCDate() ``` ```javascript (new Date(-2150668800000)).getUTCDate() ``` ```javascript (new Date(-2148249600000)).getUTCDate() ``` ```javascript (new Date(-2145571200000)).getUTCDate() ``` ```javascript (new Date(-2144966400000)).getUTCDate() ``` ```javascript (new Date(-2143756800000)).getUTCDate() ``` ```javascript (new Date(-2141942400000)).getUTCDate() ``` ```javascript (new Date(-2139523200000)).getUTCDate() ``` ```javascript (new Date(-2136931200000)).getUTCDate() ``` ```javascript (new Date(-2136326400000)).getUTCDate() ``` ```javascript (new Date(-2135116800000)).getUTCDate() ``` ```javascript (new Date(-2133302400000)).getUTCDate() ``` ```javascript (new Date(-2130883200000)).getUTCDate() ``` ```javascript (new Date(-2128204800000)).getUTCDate() ``` ```javascript (new Date(-2127600000000)).getUTCDate() ``` ```javascript (new Date(-2126390400000)).getUTCDate() ``` ```javascript (new Date(-2124576000000)).getUTCDate() ``` ```javascript (new Date(-2122156800000)).getUTCDate() ``` ```javascript (new Date(-2119564800000)).getUTCDate() ``` ```javascript (new Date(-2118960000000)).getUTCDate() ``` ```javascript (new Date(-2117750400000)).getUTCDate() ``` ```javascript (new Date(-2115936000000)).getUTCDate() ``` ```javascript (new Date(-2113516800000)).getUTCDate() ``` -------------------------------- ### Get Target Path of an Object Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/path_string/output.txt Use get() to retrieve the target path of an object. This example shows getting the target path of a variable 'o'. ```actionscript get(o) ``` -------------------------------- ### RegExp Initialization Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/class_call/output.txt Demonstrates creating RegExp objects with different arguments. ```actionscript RegExp("asdf") /asdf/ ``` ```actionscript RegExp("asdf", "gi") /asdf/gi ``` ```actionscript RegExp(regexp) /asdf/gi ``` -------------------------------- ### Browse Files Example Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/file_reference_download_success/output.txt Demonstrates calling the browse function with different configurations. Returns false if no file is selected. ```javascript // fileref.browse([]) false ``` ```javascript // fileref.browse([{ description: '' }]) false ``` ```javascript // fileref.browse([{ extension: '' }]) false ``` -------------------------------- ### Get Target Path of a Clip Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/path_string/output.txt Use get() to retrieve the target path of a movie clip. This example attempts to get the path of '_root.clip1'. ```actionscript get(_root.clip1) ``` -------------------------------- ### Download File Example Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/file_reference_download_success/output.txt Demonstrates calling the download function with various inputs. Returns false for invalid or unsuccessful downloads. ```javascript // fileref.download() false ``` ```javascript // fileref.download('@') false ``` ```javascript // fileref.download('baddomain') false ``` -------------------------------- ### Get Target Path of Null Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/path_string/output.txt Use get() to retrieve the target path of null. This example shows the behavior when the target is null. ```actionscript get(null) ``` -------------------------------- ### Setting Configuration Keys Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/init_object_order/output.txt Demonstrates setting various configuration keys with different data types. Use these for initial setup or dynamic configuration changes. ```plaintext Key: setter1 = true ``` ```plaintext Key: nonsetter = 1.1 ``` ```plaintext Key: setter2 = null ``` ```plaintext Key: setter3 = Hello ``` -------------------------------- ### Navigator::navigate_to_url GET Request Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/net_navigateToURL/output.txt This section covers the Navigator.navigate_to_url function when used with the GET method. It includes examples with and without query parameters. ```APIDOC ## GET /purchase/ ### Description Navigates to a specified URL using the GET method. This is typically used for retrieving information or viewing resources. ### Method GET ### Endpoint /purchase/ ### Query Parameters - **sku** (string) - Optional - The stock keeping unit for the item being queried. ### Request Example ```json { "URL": "https://example.com/purchase/", "Target": "_blank", "Method": "GET" } ``` ### Request Example with Query Parameter ```json { "URL": "https://example.com/purchase/?sku=Test", "Target": "_blank", "Method": "GET" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the requested data. #### Response Example ```json { "data": { "item_name": "Example Item", "price": 19.99 } } ``` ``` -------------------------------- ### Test Sound.prototype.start Method Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_gnash/actionscript.all/Sound-v8/output.txt Confirms that the start method is present on the Sound prototype. This method is used to begin playback of a sound. ```actionscript PASSED: typeof(Sound.prototype.start) == 'function' [./Sound.as:49] ``` -------------------------------- ### Install Ruffle Browser Extension Source: https://context7.com/ruffle-rs/ruffle/llms.txt Instructions for installing the Ruffle browser extension, including downloading from official stores, manual installation via ZIP, and development installation by loading unpacked extension files. ```bash # Download from official sources: # Chrome: https://chrome.google.com/webstore/detail/ruffle/donbcfbmhbcapadipfkeojnmajbakjdc # Firefox: https://addons.mozilla.org/firefox/addon/ruffle_rs/ # Firefox Android: https://addons.mozilla.org/en/android/addon/ruffle_rs/ # Manual installation (Chrome/Chromium): # 1. Download web-extension.zip from https://github.com/ruffle-rs/ruffle/releases # 2. Navigate to chrome://extensions/ # 3. Enable "Developer mode" # 4. Drag and drop the ZIP file # Development installation (Chrome): cd web npm install && npm run build # Navigate to chrome://extensions/ # Enable "Developer mode" # Click "Load unpacked" and select web/packages/extension/assets/ # Safari (macOS): # 1. Download macos-universal.tar.gz from releases # 2. Extract and open the app # 3. Enable: Safari > Preferences > Advanced > Show Develop menu # 4. Enable: Develop > Allow Unsigned Extensions # 5. Check the extension in Safari > Preferences > Extensions ``` -------------------------------- ### Array Splice Example Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/ecma3/Array/e15_4_4_12/output.txt Demonstrates the usage of the splice method on a JavaScript array. This specific example removes elements from the array starting at index 1. ```javascript MYARR = new Array( 0, 2, 3, 4, 5 ); MYARR.splice(1); PASSED! ``` ```javascript MYARR = new Array( 0, 2, 3, 4, 5 ); MYARR.splice(1); PASSED! ``` ```javascript MYARR = new Array( 0, 2, 3, 4, 5 ); MYARR.splice(1); PASSED! ``` ```javascript MYARR = new Array( 0, 2, 3, 4, 5 ); MYARR.splice(1); PASSED! ``` -------------------------------- ### Array Initialization Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/class_call/output.txt Shows various ways to initialize Array objects and their resulting lengths or contents. ```actionscript Array().length 0 ``` ```actionscript Array(5) ,,,,, ``` ```actionscript Array("5") 5 ``` ```actionscript Array("a", "b", "c") a,b,c ``` -------------------------------- ### Vector Initialization Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/class_call/output.txt Demonstrates initializing a Vector with different data types. ```actionscript Vector.([1, 2, 3]) 1,2,3 ``` ```actionscript Vector.(vec) 1,2,3 ``` ```actionscript Vector.(bytearray) 66,246,233,121 ``` -------------------------------- ### String Substr Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_gnash/actionscript.all/String-v5/output.ruffle.txt Demonstrates the usage of the substr() method for extracting substrings with different start and length parameters, including negative start indices. ```actionscript a.substr(-3,2) == "xy" ``` ```actionscript b.substr(3, 6) == "4" ``` ```actionscript o.substr(0,2) == "[o" ``` -------------------------------- ### Regex Match Index Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/ecma3/String/ematch_004/output.txt Demonstrates how to get the starting index of a regex match. ```ActionScript ( 10203040506070809000 ).match(re = /0./).index PASSED! ``` -------------------------------- ### SoundTransform Initialization with Parameters Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/soundtransform/output.txt Demonstrates creating a SoundTransform instance with initial values for pan and volume, and how subsequent pan adjustments affect other properties. ```actionscript var transform2 = new SoundTransform(0, 0.8); transform2.leftToLeft; 0.44721359549995787 transform2.leftToRight; 0 transform2.pan; 0.8 transform2.rightToLeft; 0 transform2.rightToRight; 1.3416407864998738 transform2.volume; 0 ``` ```actionscript transform2.pan = 0.9; transform2.leftToLeft; 0.3162277660168379 transform2.leftToRight; 0 transform2.pan; 0.9 transform2.rightToLeft; 0 transform2.rightToRight; 1.378404875209022 transform2.volume; 0 ``` ```actionscript transform2.pan = 1.0; transform2.leftToLeft; 0 transform2.leftToRight; 0 transform2.pan; 1 transform2.rightToLeft; 0 transform2.rightToRight; 1.4142135623730951 transform2.volume; 0 ``` ```actionscript transform2.pan = 1.1; transform2.leftToLeft; NaN transform2.leftToRight; 0 transform2.pan; NaN transform2.rightToLeft; 0 transform2.rightToRight; 1.449137674618944 transform2.volume; 0 ``` ```actionscript transform2.pan = 1.2; transform2.leftToLeft; NaN transform2.leftToRight; 0 transform2.pan; NaN transform2.rightToLeft; 0 transform2.rightToRight; 1.4832396974191326 transform2.volume; 0 ``` ```actionscript transform2.pan = -2; transform2.leftToLeft; 1.7320508075688772 transform2.leftToRight; 0 transform2.pan; -1.9999999999999996 transform2.rightToLeft; 0 transform2.rightToRight; NaN transform2.volume; 0 ``` ```actionscript transform2.pan = -1.8; transform2.leftToLeft; 1.6733200530681511 transform2.leftToRight; 0 transform2.pan; -1.8000000000000003 transform2.rightToLeft; 0 transform2.rightToRight; NaN transform2.volume; 0 ``` ```actionscript transform2.pan = -1.6; transform2.leftToLeft; 1.61245154965971 transform2.leftToRight; 0 transform2.pan; -1.6000000000000005 transform2.rightToLeft; 0 transform2.rightToRight; NaN transform2.volume; 0 ``` -------------------------------- ### Sprite Operations Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/swf4_actions_coercion_order/output.txt Examples of cloning and removing sprites, and starting drag operations. ```actionscript obj_3.valueOf()\nobj_2.toString()\nobj_1.toString() ``` ```actionscript obj_1.toString() ``` ```actionscript obj_0.toString()\nobj_1.valueOf()\nobj_7.valueOf() ``` ```actionscript obj_0.toString()\nobj_2.valueOf()\nobj_1.valueOf()\nobj_6.valueOf()\nobj_5.valueOf()\nobj_4.valueOf()\nobj_3.valueOf() ``` -------------------------------- ### Initializing BlurFilter with Parameters Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/blur_filter/output.txt Demonstrates initializing a BlurFilter with specific blurX, blurY, and quality values. ```javascript // test.filters = [new BlurFilter(-1.2, 3.4, 5)]; // test.filters[0].blurX 0 ``` ```javascript // test.filters[0].blurY 3.4 ``` ```javascript // test.filters[0].quality 5 ``` -------------------------------- ### JavaScript Array splice() with negative start index Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/array_splice/output.txt A negative start index counts from the end of the array. If the calculated start index is less than 0 after considering the array length, it defaults to 0. This example inserts 'c' at the beginning. ```javascript // splice = original.splice(-9, 0, 'c') // original c,a,b // original.length 3 // splice // splice.length 0 ``` -------------------------------- ### Create and Inspect QName Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/e4x/QName/e13_3_2/output.txt Demonstrates basic QName instantiation and property checks. Use this for understanding default values and type checking. ```javascript ns = new QName() ``` ```javascript typeof new QName('name') ``` ```javascript new QName('name') instanceof QName ``` ```javascript new QName('name') == 'name' ``` ```javascript ns = new QName('name'), ns.uri == '' ``` ```javascript ns = new QName('name'), ns.uri == null ``` ```javascript ns = new QName('name'), ns.uri == undefined ``` ```javascript ns = new QName('name'), typeof ns.uri ``` ```javascript ns = new QName('name'), ns.localName == 'name' ``` ```javascript ns = new QName(undefined) ``` ```javascript ns = new QName('') ``` -------------------------------- ### Namespace Constructor Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/namespace_constr/output.txt Demonstrates various ways to instantiate a Namespace object, showing the resulting prefix and URI. Pay attention to how different inputs like strings, null, and undefined affect the outcome, and note the TypeErrors for invalid prefix arguments. ```actionscript namespace example = "value" prefix: undefined uri: "value" ``` ```actionscript new Namespace() prefix: "" uri: "" ``` ```actionscript new Namespace(null) prefix: undefined uri: "null" ``` ```actionscript Namespace(null) prefix: undefined uri: "null" ``` ```actionscript new Namespace(undefined) prefix: undefined uri: "undefined" ``` ```actionscript Namespace(undefined) prefix: undefined uri: "undefined" ``` ```actionscript new Namespace("test") prefix: undefined uri: "test" ``` ```actionscript Namespace("test") prefix: undefined uri: "test" ``` ```actionscript new Namespace("") prefix: "" uri: "" ``` ```actionscript Namespace("") prefix: "" uri: "" ``` ```actionscript new Namespace("NOT A VALID PREFIX") prefix: undefined uri: "NOT A VALID PREFIX" ``` ```actionscript Namespace("NOT A VALID PREFIX") prefix: undefined uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace(otherNS) prefix: "otherPrefix" uri: "otherUri" ``` ```actionscript Namespace(otherNS) prefix: "otherPrefix" uri: "otherUri" ``` ```actionscript new Namespace(qName) prefix: undefined uri: "namespace" ``` ```actionscript Namespace(qName) prefix: undefined uri: "namespace" ``` ```actionscript new Namespace(null, null) prefix: undefined uri: "null" ``` ```actionscript new Namespace(null, undefined) prefix: undefined uri: "undefined" ``` ```actionscript new Namespace(null, "test") prefix: undefined uri: "test" ``` ```actionscript new Namespace(null, "") ! TypeError: Error #1098: Illegal prefix null for no namespace. ``` ```actionscript new Namespace(null, "NOT A VALID PREFIX") prefix: undefined uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace(null, otherNS) prefix: undefined uri: "otherUri" ``` ```actionscript new Namespace(null, qName) prefix: undefined uri: "namespace" ``` ```actionscript new Namespace(undefined, null) prefix: undefined uri: "null" ``` ```actionscript new Namespace(undefined, undefined) prefix: undefined uri: "undefined" ``` ```actionscript new Namespace(undefined, "test") prefix: undefined uri: "test" ``` ```actionscript new Namespace(undefined, "") ! TypeError: Error #1098: Illegal prefix undefined for no namespace. ``` ```actionscript new Namespace(undefined, "NOT A VALID PREFIX") prefix: undefined uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace(undefined, otherNS) prefix: undefined uri: "otherUri" ``` ```actionscript new Namespace(undefined, qName) prefix: undefined uri: "namespace" ``` ```actionscript new Namespace("test", null) prefix: "test" uri: "null" ``` ```actionscript new Namespace("test", undefined) prefix: "test" uri: "undefined" ``` ```actionscript new Namespace("test", "test") prefix: "test" uri: "test" ``` ```actionscript new Namespace("test", "") ! TypeError: Error #1098: Illegal prefix test for no namespace. ``` ```actionscript new Namespace("test", "NOT A VALID PREFIX") prefix: "test" uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace("test", otherNS) prefix: "test" uri: "otherUri" ``` ```actionscript new Namespace("test", qName) prefix: "test" uri: "namespace" ``` ```actionscript new Namespace("", null) prefix: "" uri: "null" ``` ```actionscript new Namespace("", undefined) prefix: "" uri: "undefined" ``` ```actionscript new Namespace("", "test") prefix: "" uri: "test" ``` ```actionscript new Namespace("", "") prefix: "" uri: "" ``` ```actionscript new Namespace("", "NOT A VALID PREFIX") prefix: "" uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace("", otherNS) prefix: "" uri: "otherUri" ``` ```actionscript new Namespace("", qName) prefix: "" uri: "namespace" ``` ```actionscript new Namespace("NOT A VALID PREFIX", null) prefix: undefined uri: "null" ``` ```actionscript new Namespace("NOT A VALID PREFIX", undefined) prefix: undefined uri: "undefined" ``` ```actionscript new Namespace("NOT A VALID PREFIX", "test") prefix: undefined uri: "test" ``` ```actionscript new Namespace("NOT A VALID PREFIX", "") ! TypeError: Error #1098: Illegal prefix NOT A VALID PREFIX for no namespace. ``` ```actionscript new Namespace("NOT A VALID PREFIX", "NOT A VALID PREFIX") prefix: undefined uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace("NOT A VALID PREFIX", otherNS) prefix: undefined uri: "otherUri" ``` ```actionscript new Namespace("NOT A VALID PREFIX", qName) prefix: undefined uri: "namespace" ``` ```actionscript new Namespace(otherNS, null) prefix: "otherUri" uri: "null" ``` ```actionscript new Namespace(otherNS, undefined) prefix: "otherUri" uri: "undefined" ``` ```actionscript new Namespace(otherNS, "test") prefix: "otherUri" uri: "test" ``` ```actionscript new Namespace(otherNS, "") ! TypeError: Error #1098: Illegal prefix otherUri for no namespace. ``` ```actionscript new Namespace(otherNS, "NOT A VALID PREFIX") prefix: "otherUri" uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace(otherNS, otherNS) prefix: "otherUri" uri: "otherUri" ``` ```actionscript new Namespace(otherNS, qName) prefix: "otherUri" uri: "namespace" ``` ```actionscript new Namespace(qName, null) prefix: undefined uri: "null" ``` ```actionscript new Namespace(qName, undefined) prefix: undefined uri: "undefined" ``` ```actionscript new Namespace(qName, "test") prefix: undefined uri: "test" ``` ```actionscript new Namespace(qName, "") ! TypeError: Error #1098: Illegal prefix namespace::name for no namespace. ``` ```actionscript new Namespace(qName, "NOT A VALID PREFIX") prefix: undefined uri: "NOT A VALID PREFIX" ``` ```actionscript new Namespace(qName, otherNS) prefix: undefined uri: "otherUri" ``` ```actionscript new Namespace(qName, qName) prefix: undefined uri: "namespace" ``` -------------------------------- ### Vector Unsigned Integer indexOf Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/vector_indexof/output.txt Provides examples of the indexOf method with unsigned integer (uint) vectors. It covers searching for existing and non-existing values, with and without a starting index. ```actionscript var a_uint: Vector. = new [1,2]; var b_uint: Vector. = new [5,16]; a_uint.indexOf(0); -1 a_uint.indexOf(1); 0 a_uint.indexOf(2); 1 b_uint.indexOf(3); -1 b_uint.indexOf(5); 0 b_uint.indexOf(12); -1 a_uint.indexOf(0, 1); -1 a_uint.indexOf(1, 1); -1 a_uint.indexOf(2, 1); 1 b_uint.indexOf(3, 1); -1 b_uint.indexOf(5, 1); -1 b_uint.indexOf(12, 1); -1 a_uint.indexOf(0, -1); -1 a_uint.indexOf(1, -1); -1 a_uint.indexOf(2, -1); 1 b_uint.indexOf(3, -1); -1 b_uint.indexOf(5, -1); -1 b_uint.indexOf(12, -1); -1 ``` -------------------------------- ### Install WiX Toolset Source: https://github.com/ruffle-rs/ruffle/blob/master/desktop/packages/windows/wix/README.md Installs the WiX Toolset globally using the .NET CLI. This is a prerequisite for building the MSI package. ```bash dotnet tool install --global wix ``` -------------------------------- ### Get Year from Date with Millisecond Offsets Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/ecma3/Date/e15_9_5_10/output.ruffle.txt These examples show how to get the current year by creating a Date object with an added millisecond offset. The offsets represent various durations like days and weeks. ```javascript (new Date(currentTime+0)).getFullYear() ``` ```javascript (new Date(currentTime+86400000)).getFullYear() ``` ```javascript (new Date(currentTime+172800000)).getFullYear() ``` ```javascript (new Date(currentTime+259200000)).getFullYear() ``` ```javascript (new Date(currentTime+345600000)).getFullYear() ``` ```javascript (new Date(currentTime+432000000)).getFullYear() ``` ```javascript (new Date(currentTime+518400000)).getFullYear() ``` ```javascript (new Date(currentTime+604800000)).getFullYear() ``` ```javascript (new Date(currentTime+691200000)).getFullYear() ``` ```javascript (new Date(currentTime+777600000)).getFullYear() ``` ```javascript (new Date(currentTime+864000000)).getFullYear() ``` ```javascript (new Date(currentTime+950400000)).getFullYear() ``` ```javascript (new Date(currentTime+1036800000)).getFullYear() ``` ```javascript (new Date(currentTime+1123200000)).getFullYear() ``` ```javascript (new Date(currentTime+1209600000)).getFullYear() ``` ```javascript (new Date(currentTime+1296000000)).getFullYear() ``` ```javascript (new Date(currentTime+1382400000)).getFullYear() ``` ```javascript (new Date(currentTime+1468800000)).getFullYear() ``` ```javascript (new Date(currentTime+1555200000)).getFullYear() ``` ```javascript (new Date(currentTime+1641600000)).getFullYear() ``` ```javascript (new Date(currentTime+1728000000)).getFullYear() ``` ```javascript (new Date(currentTime+1814400000)).getFullYear() ``` ```javascript (new Date(currentTime+1900800000)).getFullYear() ``` ```javascript (new Date(currentTime+1987200000)).getFullYear() ``` ```javascript (new Date(currentTime+2073600000)).getFullYear() ``` ```javascript (new Date(currentTime+2160000000)).getFullYear() ``` ```javascript (new Date(currentTime+2246400000)).getFullYear() ``` ```javascript (new Date(currentTime+2332800000)).getFullYear() ``` ```javascript (new Date(currentTime+2419200000)).getFullYear() ``` ```javascript (new Date(currentTime+2505600000)).getFullYear() ``` -------------------------------- ### Connect to NetConnection (HTTP) Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/netconnection_close/output.txt Use connection.connect("http://example.org") to establish a connection to a specified URL. This can result in various NetStatusEvents, including connection success or closure. ```actionscript connection.connect("http://example.org") ``` ```actionscript -- NetStatusEvent.NET_STATUS event start -- event.type = netStatus event.bubbles = false event.cancelable = false event.info.code = NetConnection.Connect.Closed (string) event.info.level = status (string) -- NetStatusEvent.NET_STATUS event end -- ``` ```actionscript -- NetStatusEvent.NET_STATUS event start -- event.type = netStatus event.bubbles = false event.cancelable = false event.info.code = (string) event.info.description = (string) event.info.details = (string) event.info.level = status (string) -- NetStatusEvent.NET_STATUS event end -- ``` -------------------------------- ### Initialize Ruffle Player and Load SWF via JavaScript Source: https://context7.com/ruffle-rs/ruffle/llms.txt This example demonstrates initializing the Ruffle player, creating a player element, appending it to the DOM, and loading a SWF file with various configuration options. It also includes event listeners for metadata and data loading. ```html Ruffle JavaScript API Example
``` -------------------------------- ### EventDispatcher Example Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/eventdispatcher_dispatchevent/output.txt Demonstrates basic event dispatching and listening using EventDispatcher. Requires EventDispatcher to be instantiated. ```javascript //var evtd = new EventDispatcher(); //evtd.addEventListener('test', introspect_event, false, 0); //evtd.dispatchEvent('test'); ``` -------------------------------- ### Get Style Example Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/stylesheet/output.txt Demonstrates retrieving styles for a given selector. If the selector does not exist, an empty object is returned. ```rust styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("blank") = {} styleSheet.getStyle("null") = {} styleSheet.getStyle("object") = {} styleSheet.getStyle("string") = {} styleSheet.getStyle("undefined") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("blank") = {} styleSheet.getStyle("null") = {} styleSheet.getStyle("object") = {} styleSheet.getStyle("string") = {} styleSheet.getStyle("undefined") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("one") = { "color" = string "red" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("one") = { "color" = string "red" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("one") = { "kerning" = string "5 " } styleSheet.getStyle("two") = { "color" = string "red" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "kerning" = string "5 " } styleSheet.getStyle("b") = { "kerning" = string "5 " } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a.b.c-d!#@$😜") = { "worked" = string "honestly, I'm surprised too! " } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("key") = { "color" = string "pink" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("") = { "color" = string "" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("test\\") = { "color" = string "\\" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("\"test\"") = { "color" = string "\"red\"" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a}") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "" = string "" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("b") = { ";;key" = string "value" ";other" = string "value" } styleSheet.getStyle("c") = { ";;key" = string "value" "other" = string "value" } styleSheet.getStyle("e") = { "key;other" = string "value" } styleSheet.getStyle("f") = { ";" = string "value" } styleSheet.getStyle("g") = { "key" = string "value" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "name}b{" = string "value" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "key" = string "" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "key" = string "" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "" = string "" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("key") = { "PROPERTY" = string "VALUE" "Property" = string "Value" "property" = string "value" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("key") = { "property " = string "test value " } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("key") = { "UPPERDASHES" = string "value" "nameWithDashes" = string "value name-with-dashes-and-spaces : value" "this-one-has-two-dashes" = string "value" } styleSheet.getStyle("nonexistant") = {} styleSheet.getStyle("a") = { "key1" = string "value" "key2" = string "value " } ``` -------------------------------- ### Rectangle Constructor Examples Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/rectangle/output.txt Illustrates different ways to instantiate a Rectangle object, showing how arguments map to properties. ```javascript new Rectangle() (top=0, right=0, bottom=0, left=0, topLeft=(x=0, y=0), bottomRight=(x=0, y=0), width=0, height=0, size=(x=0, y=0), x=0, y=0) ``` ```javascript new Rectangle(1) (top=undefined, right=NaN, bottom=NaN, left=1, topLeft=(x=1, y=undefined), bottomRight=(x=NaN, y=NaN), width=undefined, height=undefined, size=(x=undefined, y=undefined), x=1, y=undefined) ``` ```javascript new Rectangle(1, 2) (top=2, right=NaN, bottom=NaN, left=1, topLeft=(x=1, y=2), bottomRight=(x=NaN, y=NaN), width=undefined, height=undefined, size=(x=undefined, y=undefined), x=1, y=2) ``` ```javascript new Rectangle(1, 2, 3) (top=2, right=4, bottom=NaN, left=1, topLeft=(x=1, y=2), bottomRight=(x=4, y=NaN), width=3, height=undefined, size=(x=3, y=undefined), x=1, y=2) ``` ```javascript new Rectangle(1, 2, 3, 4) (top=2, right=4, bottom=6, left=1, topLeft=(x=1, y=2), bottomRight=(x=4, y=6), width=3, height=4, size=(x=3, y=4), x=1, y=2) ``` ```javascript new Rectangle({}) (top=undefined, right=NaN, bottom=NaN, left=[object Object], topLeft=(x=[object Object], y=undefined), bottomRight=(x=NaN, y=NaN), width=undefined, height=undefined, size=(x=undefined, y=undefined), x=[object Object], y=undefined) ``` -------------------------------- ### Get Milliseconds from Epoch Start Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/ecma3/Date/e15_9_5_21_1/output.txt Demonstrates retrieving milliseconds from the Unix epoch (January 1, 1970, 00:00:00 UTC). ```javascript (new Date(0)).getUTCMilliseconds() ``` -------------------------------- ### Creating a GlowFilter Instance Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/glow_filter/output.txt Shows how to create a new GlowFilter instance with default parameters and then how to create one with specific constructor arguments. ```javascript // test.filters = [new GlowFilter()]; // test.filters[0].alpha 1 // test.filters[0].blurX 6 // test.filters[0].blurY 6 // test.filters[0].color 16711680 // test.filters[0].inner false // test.filters[0].knockout false // test.filters[0].quality 1 // test.filters[0].strength 2 ``` ```javascript // test.filters = [new GlowFilter(0xABCDEF, 0.2, -1, 2.3, 4, 2, true, true)]; // test.filters[0].alpha 0.2 // test.filters[0].blurX 0 // test.filters[0].blurY 2.3 // test.filters[0].color 11259375 // test.filters[0].inner true // test.filters[0].knockout true // test.filters[0].quality 2 // test.filters[0].strength 4 ``` -------------------------------- ### Get Time in Milliseconds (Near Epoch) Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/from_avmplus/ecma3/Date/e15_9_4_2/output.txt Retrieves the number of milliseconds since the ECMAScript epoch for a date just before and at the start of the epoch hour. ```javascript new Date(28799999).getTime() ``` ```javascript new Date(28799999).valueOf() ``` ```javascript new Date(28800000).getTime() ``` ```javascript new Date(28800000).valueOf() ``` -------------------------------- ### Building Ruffle from Source Source: https://context7.com/ruffle-rs/ruffle/llms.txt Instructions for building Ruffle for desktop and web platforms, including setting up prerequisites and running tests. ```APIDOC ## Building Ruffle from Source Build Ruffle for various platforms with the following commands. Prerequisites include Rust, Java, and Node.js. ### Prerequisites Ensure you have Rust, Java, and Node.js installed. For web builds, you'll need the WebAssembly target for Rust. ```bash # Install Rust prerequisites rustup update stable rustup target add wasm32-unknown-unknown # For web builds ``` ### Desktop Builds Compile Ruffle for desktop use, both in debug and release modes. ```bash # Desktop build (debug) cargo build --package=ruffle_desktop # Desktop build (release, optimized) cargo build --release --package=ruffle_desktop ``` ### Web/Browser Extension Builds Navigate to the `web` directory and use npm to build the web version of Ruffle. ```bash cd web npm install npm run build # Production build npm run build:debug # Debug build with verbose AS logging npm run build:dual-wasm # Build with WebAssembly extension fallback ``` ### Running Local Web Demo Start a local development server to test the web version. ```bash npm run demo ``` ### Running Tests Execute the test suites for Ruffle, including optional image comparison tests. ```bash cargo test --all # All Rust tests cargo test --all --features imgtests # Include image comparison tests cd web && npm run test # Web/JS tests ``` ### Linting and Formatting Maintain code quality and consistency using Rust's formatting and linting tools. ```bash cargo fmt --all cargo clippy --all --tests cd web && npm run format ``` ``` -------------------------------- ### Navigate to Clip with Ellipsis Suffix Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/path_string/output.txt Use ellipsis (...) as a suffix to navigate to a clip. This example demonstrates getting the target path. ```actionscript get('_root:clip1:clip2...clip2') ``` -------------------------------- ### Initialize and Populate Dictionary Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm2/dictionary_foreach/output.txt Demonstrates initializing a Dictionary and assigning values to properties using different key types, including objects and their string representations. ```javascript var a = new Dictionary() a["key"] = 5 a["key"] 5 a["key"] = 6 var key2 = new Test() a[key2] = 23 var key3 = new Test() a[key3] = "Key3 True Value" a["key3"] = "Key3 False Value" var key4 = {"toString": function() { return "key4"; }} a[key4] = "Key4 True Value" a["key4"] = "Key4 False Value" a[13] = "i've been found!" a["13"] = "no I haven't" a[1.123] = "this violates Rust!" a["1.123"] = "this is perfectly acceptable" a[undefined] = "oh no" a["undefined"] = "uh huh..." a[null] = "oh YES!" a["null"] = "yeah sure" a[true] = "true" a["true"] = "stringy true" a[false] = "false" a["false"] = "stringy false" a[a] = a ``` -------------------------------- ### Navigate to Clip with Ellipsis Prefix Source: https://github.com/ruffle-rs/ruffle/blob/master/tests/tests/swfs/avm1/path_string/output.txt Use ellipsis (...) as a prefix to navigate to a clip. This example demonstrates getting the target path. ```actionscript get('_root:clip1:clip2/...clip2') ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/ruffle-rs/ruffle/blob/master/web/README.md Run this command every time you pull new changes to ensure all necessary packages are installed. Failure to do so may result in a failed build. ```bash npm install ```