Protect your ActionScript with Amayeta’s SWF Encrypt

Ok… you made it… you made the Flash game that will kick asses and you are sure nobody knows Actionscript like you. Nobody will clone your game because you know ActionScript better than the rest.

If you really know ActionScript, you should now that even if SWF files are compiled, they can be easily decompiled with a lot of softwares available on the net. Just Google for Flash Decompiler to see the most famous ones.

This means that once you published your file, everybody can do reverse engineering on your file and know how did you coded it.

And even if bigger projects are hard to understand, someone may decompile your game, change your logo with another one and submit it in all portals before you do it.

If you think people won’t waste their time decompiling your game, you are wrong. They will do it… maybe to hack your highscores, or maybe to put their name in the credits and show their friends what a cool game they made… for a reason or for another, they will do it.

That’s when Amayeta comes in our help with its SWF Encrypt. Available both for Windos and Mac OSX encrypts your Adobe Flash SWF files, protecting them from the most popular Flash Decompiler Tools on the market.

Sounds good… here I am for a test drive…

Amayeta’s SWF Encrypt (ASWFE from now on) takes less than 5MB on your hard drive, and once you lauch it you will see this screen:

Amayeta SWF Encrypt

ASWFE shows your unprotected SWF files with a red background and the protected ones with a green background.

In the bottom window you can preview the movie you currently selected. As you can see, I am trying to protect my prototype of Metro Siberia Underground game.

Now just press Encrypt File(s) and you will find a SWF file with the _secure suffix. In my case, the original file was 1butt3.swf, and the new one is 1butt3_secure.swf. Please notice that I did not change any option, and I don’t play with strange setups. ASWFE works very well with default options, and all you have to do is pressing a button.

But the final question is: will it work? I tried to decompile 1butt3.swf, the unprotected file, and that’s what I got:

// Action script...

// [Action in Frame 1]
var ship_filter = new flash.filters.GlowFilter(65280, 8.000000E-001, 4, 4, 2, 3, false, false);
var smoke_filter = new flash.filters.GlowFilter(16711680, 8.000000E-001, 4, 4, 2, 3, false, false);
var tunnel_filter = new flash.filters.GlowFilter(16776960, 8.000000E-001, 4, 4, 2, 3, false, false);
var fuel_filter = new flash.filters.GlowFilter(65535, 8.000000E-001, 4, 4, 2, 3, false, false);
var rock_filter = new flash.filters.GlowFilter(16777215, 8.000000E-001, 4, 4, 2, 3, false, false);
var score_filter = new flash.filters.GlowFilter(16711935, 8.000000E-001, 2, 4, 2, 3, false, false);
gravity = 1.000000E-001;
thrust = 2.500000E-001;
yspeed = 0;
xspeed = 5;
distance = 0;
smoke_interval = 10000;
frames_passed = 0;
tunnel_height = 150;
fuel_freq = 10;
gasoline = 500;
rock_freq = 50;
engines = false;
_root.attachMovie("ship", "ship", _root.getNextHighestDepth(), {_x: 150, _y: 200});
_root.createEmptyMovieClip("fuel_movie", _root.getNextHighestDepth());
_root.createEmptyMovieClip("deadly_movie", _root.getNextHighestDepth());
_root.attachMovie("score", "score", _root.getNextHighestDepth());
ship.filters = new Array(ship_filter);
score.filters = new Array(score_filter);
ship.onEnterFrame = function ()
{
    score.sc.text = "Distance: " + distance + " - " + "Fuel: " + gasoline;
    if (gasoline > 0 && engines)
    {
        yspeed = yspeed - thrust;
        smoke_interval = smoke_interval - 2.500000E-001;
        gasoline = gasoline - 1;
    } // end if
    if (Math.random() * 1000 < fuel_freq)
    {
        fuel = fuel_movie.attachMovie("fuel", "fuel" + fuel_movie.getNextHighestDepth(), fuel_movie.getNextHighestDepth(), {_x: 510, _y: Math.random() * 400 + 50});
        fuel.filters = new Array(fuel_filter);
        fuel.onEnterFrame = function ()
        {
            this._x = this._x - xspeed * 1.200000E+000;
            dist_x = ship._x + 28 * Math.cos(angle) - this._x;
            dist_y = ship._y + 28 * Math.sin(angle) - this._y;
            dist = Math.sqrt(dist_x * dist_x + dist_y * dist_y);
            if (dist < 10)
            {
                gasoline = gasoline + 100;
                this.removeMovieClip();
            } // end if
            if (this._x < -10)
            {
                this.removeMovieClip();
            } // end if
        };
    } // end if
    if (Math.random() * 1000 < rock_freq)
    {
        rock = deadly_movie.attachMovie("rock", "rock" + deadly_movie.getNextHighestDepth(), deadly_movie.getNextHighestDepth(), {_x: 510, _y: Math.random() * 400 + 50, _rotation: Math.random() * 360});
        rock.filters = new Array(rock_filter);
        rock.onEnterFrame = function ()
        {
            this._x = this._x - xspeed;
            if (this._x < -10)
            {
                this.removeMovieClip();
            } // end if
        };
    } // end if
    yspeed = yspeed + gravity;
    this._y = this._y + yspeed;
    angle = Math.atan2(yspeed, xspeed);
    this._rotation = angle * 180 / 3.141593E+000;
    ++frames_passed;
    distance = distance + xspeed;
    if (frames_passed >= smoke_interval)
    {
        sm = _root.attachMovie("smoke", "smoke" + _root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x: this._x - 2, _y: this._y});
        sm.filters = new Array(smoke_filter);
        sm.onEnterFrame = function ()
        {
            this._x = this._x - xspeed;
            this._width = this._width + 2.000000E-001;
            this._height = this._height + 2.000000E-001;
            this._alpha = this._alpha - 2;
            if (this._alpha <= 0)
            {
                this.removeMovieClip();
            } // end if
        };
        frames_passed = 0;
    } // end if
    if (this._y > 400 || this._y < 0 || deadly_movie.hitTest(this._x + 28 * Math.cos(angle), this._y + 28 * Math.sin(angle), true) || deadly_movie.hitTest(this._x + 8 * Math.cos(angle + 1.570796E+000), this._y + 8 * Math.sin(angle + 1.570796E+000), true) || deadly_movie.hitTest(this._x + 8 * Math.cos(angle - 1.570796E+000), this._y + 8 * Math.sin(angle - 1.570796E+000), true))
    {
        yspeed = 0;
        this._y = 200;
        gasoline = 500;
        distance = 0;
        deadly_movie.removeMovieClip();
        fuel_movie.removeMovieClip();
        _root.createEmptyMovieClip("fuel_movie", _root.getNextHighestDepth());
        _root.createEmptyMovieClip("deadly_movie", _root.getNextHighestDepth());
    } // end if
};
_root.onMouseDown = function ()
{
    engines = true;
    smoke_interval = 10;
};
_root.onMouseUp = function ()
{
    engines = false;
    smoke_interval = 100000;
};

It changed some logical operators (or with ||) and made some minor changes, but the code is perfectly readable.

Now, let's decompile the protected file:

// Action script...

// [Action in Frame 1]
function ()
{
    \x03 = 2568 % 511 * 5;
    return (eval("\x03"));
} // End of the function
var \x01 = 439 + \x04\x05();
for (\x01 = eval("\x01") - 372; eval("\x01") == 590; \x01 = eval("\x01") + 140)
{
} // end of for
if (eval("\x01") == 933)
{
    \x01 = eval("\x01") - 21;
    
}
else
{
    \x01 = eval("\x01") - 51;
    var null = true;
    if (eval("\x01") == 810)
    {
        \x01 = eval("\x01") + 123;
        
    } // end if
    if (eval("\x01") == 636)
    {
        \x01 = eval("\x01") - 46;
        
        
    } // end if
    if (eval("\x01") == 132)
    {
        \x01 = eval("\x01") + 504;
        if (!null)
        {
        }
        else
        {
            \x01 = eval("\x01") - 46;
        } // end else if
        
    } // end if
    if (eval("\x01") == 594)
    {
        \x01 = eval("\x01") - 8;
        
    } // end if
    if (eval("\x01") == 872)
    {
        \x01 = eval("\x01") - 142;
        
    } // end if
    if (eval("\x01") == 96)
    {
        \x01 = eval("\x01") + 714;
        if (!null)
        {
        }
        else
        {
            \x01 = eval("\x01") + 123;
        } // end else if
        
    } // end if
    \x01 = eval("\x01") + 223;
    if (eval("\x01") == 116)
    {
        \x01 = eval("\x01") - 20;
        
    } // end if
    if (eval("\x01") == 687)
    {
        \x01 = eval("\x01") - 571;
        
    } // end if
    if (eval("\x01") == 953)
    {
        \x01 = eval("\x01") - 574;
        if (true)
        {
        }
        else
        {
            \x01 = eval("\x01") + 319;
        } // end else if
        
    } // end if
    if (eval("\x01") == 912)
    {
        \x01 = eval("\x01") - 912;
        
    } // end if
    \x01 = eval("\x01") - 199;
    if (eval("\x01") == 379)
    {
        \x01 = eval("\x01") + 319;
        
        
    } // end if
    if (eval("\x01") == 698)
    {
        \x01 = eval("\x01") - 112;
        
    } // end if
    \x01 = eval("\x01") + 351;
    
} // end else if

What a mess! The script s full of strange variables and if you try to execute it in Flash, it will produce tons of errors.

The script is definitively unreadable.

Try before buy

You can download a trial version limited to 15 encryptions and displaying a watermark on your file (useless if you publish your work in the web, useful if you submit a game to Flash Game License) or buy it at $125. If you want to get serious in ActionScript development, you need to protect your work, and at the moment ASWFE is the perfect solution.

Get the most popular Phaser 3 book

Through 202 pages, 32 source code examples and an Android Studio project you will learn how to build cross platform HTML5 games and create a complete game along the way.

Get the book

215 GAME PROTOTYPES EXPLAINED WITH SOURCE CODE
// 1+2=3
// 100 rounds
// 10000000
// 2 Cars
// 2048
// A Blocky Christmas
// A Jumping Block
// A Life of Logic
// Angry Birds
// Angry Birds Space
// Artillery
// Astro-PANIC!
// Avoider
// Back to Square One
// Ball Game
// Ball vs Ball
// Ball: Revamped
// Balloon Invasion
// BallPusher
// Ballz
// Bar Balance
// Bejeweled
// Biggification
// Block it
// Blockage
// Bloons
// Boids
// Bombuzal
// Boom Dots
// Bouncing Ball
// Bouncing Ball 2
// Bouncy Light
// BoxHead
// Breakout
// Bricks
// Bubble Chaos
// Bubbles 2
// Card Game
// Castle Ramble
// Chronotron
// Circle Chain
// Circle Path
// Circle Race
// Circular endless runner
// Cirplosion
// CLOCKS - The Game
// Color Hit
// Color Jump
// ColorFill
// Columns
// Concentration
// Crossy Road
// Crush the Castle
// Cube Jump
// CubesOut
// Dash N Blast
// Dashy Panda
// Deflection
// Diamond Digger Saga
// Don't touch the spikes
// Dots
// Down The Mountain
// Drag and Match
// Draw Game
// Drop Wizard
// DROP'd
// Dudeski
// Dungeon Raid
// Educational Game
// Elasticity
// Endless Runner
// Erase Box
// Eskiv
// Farm Heroes Saga
// Filler
// Flappy Bird
// Fling
// Flipping Legend
// Floaty Light
// Fuse Ballz
// GearTaker
// Gem Sweeper
// Globe
// Goat Rider
// Gold Miner
// Grindstone
// GuessNext
// Helicopter
// Hero Emblems
// Hero Slide
// Hexagonal Tiles
// HookPod
// Hop Hop Hop Underwater
// Horizontal Endless Runner
// Hundreds
// Hungry Hero
// Hurry it's Christmas
// InkTd
// Iromeku
// Jet Set Willy
// Jigsaw Game
// Knife Hit
// Knightfall
// Legends of Runeterra
// Lep's World
// Line Rider
// Lumines
// Magick
// MagOrMin
// Mass Attack
// Math Game
// Maze
// Meeblings
// Memdot
// Metro Siberia Underground
// Mike Dangers
// Mikey Hooks
// Nano War
// Nodes
// o:anquan
// One Button Game
// One Tap RPG
// Ononmin
// Pacco
// Perfect Square!
// Perfectionism
// Phyballs
// Pixel Purge
// PixelField
// Planet Revenge
// Plants Vs Zombies
// Platform
// Platform game
// Plus+Plus
// Pocket Snap
// Poker
// Pool
// Pop the Lock
// Pop to Save
// Poux
// Pudi
// Pumpkin Story
// Puppet Bird
// Pyramids of Ra
// qomp
// Quick Switch
// Racing
// Radical
// Rebuild Chile
// Renju
// Rise Above
// Risky Road
// Roguelike
// Roly Poly
// Run Around
// Rush Hour
// SameGame
// SamePhysics
// Save the Totem
// Security
// Serious Scramblers
// Shrink it
// Sling
// Slingy
// Snowflakes
// Sokoban
// Space Checkers
// Space is Key
// Spellfall
// Spinny Gun
// Splitter
// Spring Ninja
// Sproing
// Stabilize!
// Stack
// Stairs
// Stick Hero
// String Avoider
// Stringy
// Sudoku
// Super Mario Bros
// Surfingers
// Survival Horror
// Talesworth Adventure
// Tetris
// The Impossible Line
// The Moops - Combos of Joy
// The Next Arrow
// Threes
// Tic Tac Toe
// Timberman
// Tiny Wings
// Tipsy Tower
// Toony
// Totem Destroyer
// Tower Defense
// Trick Shot
// Tunnelball
// Turn
// Turnellio
// TwinSpin
// vvvvvv
// Warp Shift
// Way of an Idea
// Whack a Creep
// Wheel of Fortune
// Where's my Water
// Wish Upon a Star
// Word Game
// Wordle
// Worms
// Yanga
// Yeah Bunny
// Zhed
// zNumbers