Proper Ways to Save .sol, .swf Game Data using Ruffle?

Abstract: Resolve unreliable .sol saves in Ruffle by using ActionScript 3 JSON serialization and ExternalInterface to store data in browser LocalStorage.

Created: 2026-09-02 by
To save game data in Ruffle, you must implement a custom storage solution because the built-in manager is unreliable. The most robust method involves using ActionScript 3 to serialize data into JSON strings and storing them via the browser's LocalStorage API. This approach bypasses Ruffle’s internal file system limitations while ensuring persistent saves across sessions.

Understanding Ruffle Storage Limitations

Ruffle is an open-source Flash Player emulator that runs SWF files in modern web browsers. While it aims for compatibility, its handling of local file I/O operations differs significantly from the original Adobe Flash Player. The original Flash environment used SharedObject instances to store .sol files directly on the user's disk. In the browser context, direct disk access is restricted by security sandbox rules. Consequently, Ruffle’s default attempt to mimic this behavior often fails or behaves inconsistently across different browsers and configurations.

Developers frequently encounter situations where saved games disappear after refreshing the page or where the save dialog never appears. This is not necessarily a bug in your code but a mismatch between legacy Flash expectations and modern web standards. To resolve this, you need to decouple your game logic from the specific .sol file format and instead use web-native storage mechanisms.

Implementing Custom Save Logic

The foundation of any reliable save system in Ruffle is proper data serialization. You cannot simply write raw objects to a file; you must convert them into a string format that can be stored as text. In ActionScript 3, which powers most .swf games, you should use the built-in JSON class if available, or a lightweight library like as3corelib. Avoid non-standard methods like JSON.encode(), as this is not part of the AS3 specification and will cause runtime errors in strict environments.

  1. Create a Data Model: Define a class that holds all variables you wish to persist, such as player health, inventory items, or level progress.
  2. Serialize to String: Use JSON.stringify(yourData) to convert your object into a single string. Ensure all keys are unique and values are primitive types (strings, numbers, booleans) or nested arrays/objects.
  3. Store in LocalStorage: Access the browser’s window.localStorage object through ExternalInterface. Assign your serialized string to a key, such as "game_save_v1".

This method ensures that your data survives page reloads because LocalStorage is designed for exactly this purpose. It is supported by all major browsers that support Ruffle, including Chrome, Firefox, and Safari.

Bridging ActionScript and JavaScript

To interact with LocalStorage, you need a bridge between your SWF content and the HTML page hosting it. Ruffle exposes the ExternalInterface API, allowing ActionScript to call JavaScript functions. You can create a simple wrapper function in your HTML that handles the actual storage operations.

// JavaScript side (in your HTML file)
function saveGameData(key, value) {
    try {
        localStorage.setItem(key, value);
        return true;
    } catch (e) {
        console.error("Save failed:", e);
        return false;
    }
}

function loadGameData(key) {
    return localStorage.getItem(key);
}

In your ActionScript code, you then invoke these functions:

// ActionScript side
import flash.external.ExternalInterface;

var dataString:String = JSON.stringify(myGameData);
var success:Boolean = ExternalInterface.call("saveGameData", "my_save_key", dataString);

if (success) {
    trace("Game saved successfully.");
} else {
    trace("Failed to save game.");
}

This separation of concerns keeps your game logic clean and leverages the browser’s native capabilities. It also makes debugging easier, as you can inspect the LocalStorage entries directly in your browser’s developer tools under the Application tab.

Loading and Deserializing Data

Saving is only half the equation; loading the data back into the game state is equally critical. When the game initializes, check for existing save data before proceeding to the main menu. Retrieve the string from LocalStorage and parse it back into an object structure.

// ActionScript side
var savedJson:String = ExternalInterface.call("loadGameData", "my_save_key");
if (savedJson != null && savedJson.length > 0) {
    var myGameData:Object = JSON.parse(savedJson);
    // Apply loaded values to current game state
    playerHealth = Number(myGameData.health);
    currentLevel = int(myGameData.level);
}

Always include error handling around JSON.parse(). If the saved data is corrupted or empty, the parser will throw an exception. Wrap this in a try-catch block to ensure your game doesn’t crash on startup. If parsing fails, initialize default values instead of attempting to use malformed data.

Handling Multiple Saves and Backups

For more complex games, you may want to support multiple save slots. You can achieve this by appending a slot identifier to your storage key, such as "save_slot_1" and "save_slot_2". Additionally, consider implementing a backup mechanism. Since LocalStorage has a size limit (typically 5-10MB), large games might exceed this capacity. If you anticipate large data sets, look into Best Way to Handle Remote Storage Without Local Copy to offload data to a server or use IndexedDB for larger capacities.

Another consideration is data integrity. Before overwriting a save slot, you might want to verify that the new data is valid. Write a validation function that checks for required fields and reasonable value ranges. This prevents players from accidentally corrupting their progress due to bugs or exploits.

Frequently Asked Questions

Why does my save disappear after closing the browser?

If your saves vanish, you are likely relying on session-only storage or temporary cookies. Ensure you are using localStorage rather than sessionStorage. LocalStorage persists indefinitely until manually cleared by the user, whereas sessionStorage is deleted when the tab closes.

Can I still use SharedObject in Ruffle?

While Ruffle attempts to support some legacy APIs, SharedObject behavior is inconsistent and often blocked by modern security policies. It is highly recommended to migrate to the LocalStorage + ExternalInterface pattern for reliable results across all platforms.

What is the maximum size for a saved game?

Browser LocalStorage typically allows between 5MB and 10MB per domain. For most 2D games, this is sufficient. If you are storing high-resolution images or extensive logs, you may hit this limit quickly. In such cases, consider compressing your data or using IndexedDB.

How do I clear saved data for testing?

You can clear all saved data by opening your browser’s Developer Tools (F12), navigating to the Application tab, selecting Local Storage, and clicking the trash icon next to your domain. Alternatively, add a debug command in your game to trigger localStorage.clear() via ExternalInterface.

Is this method compatible with mobile browsers?

Yes, both iOS Safari and Android Chrome support LocalStorage and ExternalInterface calls. However, be aware that some mobile browsers may restrict storage quotas more aggressively than desktop versions. Always test your save functionality on actual mobile devices before release.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More