What goes into a Flash menu
The main menu, the server browser, the options and the end-of-round screens are Flash movies. The
original plays them with SwiffPlayer.dll, a build of the open-source gameswf player; the movies draw
their own art and call the game through native objects under _global.dice. bf2-rs plays the same
files with Ruffle plus a patch set that makes it behave like that gameswf build.
The files#
A menu is a SWF 7 movie with ActionScript 2 bytecode, under Menu/External/FlashMenu/. Its art is partly inside the movie (vector shapes, embedded bitmaps) and partly loaded at run time from images next to it (loadMovie of a .png, .dds or .tga, resolved through the file system like any other file). 2142 and Heroes ship their movies as .dfm: the SWF bytes XOR the key 0B AD F0 0D repeating (SwiffPlayer.dll@2142!0x101019f4), decrypted on load (bf2_ui::swf::decode_dfm).
The movies never use fscommand or getURL. Everything the game provides, from the server list to the player's name, comes from native methods that SwiffPlayer registers, for example dice.bf2.Logic.active, dice.bf2.Locale.getString, dice.bf2.Cursor.setCursor; Heroes adds its own under dice.bfh. The retail table of those natives (object paths, methods, handler addresses) is re/data/flash_api.tsv, what each one does re/data/flash_natives.tsv.
How our player draws them#
| Part | What it does | bf2-rs |
|---|---|---|
| the natives | the game side of every dice.* method: argument rules, the settings, the lists the menus page through | crates/bf2-ui (host.rs, natives*.rs, lists*), Heroes' in crates/bfh-ui |
| the player | Ruffle with the gameswf patch set: number printing, depth counters, edit text, the frame and event order of gameswf | crates/bf2-ui/player (Bf2Host), Ruffle in third_party/ruffle-bf2 |
| the screen | the movie is stretched to the window (ISwiff::setScale(screen_w / movie_w, screen_h / movie_h), BF2.exe!0x004a2fb0); the client draws Ruffle's wgpu output over the 3D view | the client app's menu.rs, Ruffle's wgpu renderer |
| engine text | menu labels drawn with the game's bitmap fonts instead of Flash fonts, as SwiffRender does | bf2-ui swiff_text.rs, bf2-font |

The frame is the movie on its own: the logo, the header and the footer bars are its art, the empty panels are what the lobby fills once a session exists (the login, the hero list, the store). The same player renders the scripted menu walkthroughs of the test suite (examples/walkthrough.rs, one image hash per frame) and the menus in the browser build. The in-game HUD is not Flash in any of the three games: it is built from the game's BFMeme .con layout (crates/bf2-hud) and drawn as quads in the last stage of the render pipeline.
Per game#
| BF2 | 2142 | Heroes 1.126 | |
|---|---|---|---|
| movies | .swf in Menu_client.zip | .dfm in the Menu_*.zip archives (mainMenu.dfm), encrypted | two .dfm: mainMenu_west.dfm (1.7 MB) and endOfRound_west.dfm in Menu_server.zip |
| art | inside the movies plus images | the same | Menu_client.zip holds 6,562 images (DDS, PNG, TGA, JPG): items, abilities, store art |
| natives | natives.rs, natives2*, natives3, natives4 | natives2142.rs (BFHQ, unlocks, the diagram) | crates/bfh-ui (store, missions, friends, server browser, hero preview) |
| player | SwiffPlayer.dll | SwiffPlayer.dll@2142 | SwiffPlayer.dll@bfh126, loaded by MainMenuLogic::activate (BFHeroes.exe!0x004c9219, bf2-client frontend.rs) |
How it is tested#
- The menu's data against the original (
crates/bf2-ui/tests): the end-of-round data, the award and kit catalogues, and number-to-text conversions, each against the original's own function or C runtime (the Flash layer). - Every shipped font file is read (
crates/bf2-font/tests/retail.rs). - The movies themselves are the game's files, played by a third-party player with the project's patches; no test compares its drawing with the original player's.
Where it is read and drawn#
| Step | bf2-rs |
|---|---|
| decrypt, patch in memory | bf2-ui swf.rs (decode_dfm, inject_init_action) |
| natives | bf2-ui natives*.rs, bfh-ui |
| play and draw | crates/bf2-ui/player (Ruffle), the client app's menu layer |
| the picture | crates/bf2-ui/player/examples/menu_frame.rs |
The full analysis (the ISwiff interface, gameswf behaviour, every native, the Ruffle patches) is notes/subsystems/menu-flash.md.
docs/dev/assets/flash.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.