开发者

How do I make sure the SWF file from my AIR project can't be opened like a regular SWF file?

I'm making a game with Flash CS5.5 and exporting it to a APK file (AIR for Android).

The trouble is that the APK file is really just a ZIP file, so you can extract the content and inside there is my game as a regular SW开发者_Go百科F file. Anyone can upload this to any website and play the game there.

I don't want the SWF file to work unless opened like it should, inside the APK file through Android.

Is there any way to know through ActionScript 3 code if the SWF file has been extracted from the APK file and has been opened as a normal SWF file?


A swf will "open" no matter what. You might however, do a check in your Document Class for what the OS is before deciding whether or not to actually allow the swf to run any more code. Look at flash.system.Capabilities and you'll find tools that let you sniff the OS.


First Thing to note: technically there are absolutely no ways you can stop a patient and dedicated person from unpacking and trying to use you SWF on the web.

BUT what you really can do is you can make a hacker suffer and have hard times reversing your code. In reality that's the only thing that matters: you may state that your app is protected when the cost of efforts and profit of breaking the defences is comparable to the cost of defending the app.

  • In your code check anything you can to detect a launch in Android environment. OS, like scriptocalypse suggested and/or availability of Android API. Block application from starting in inappropriate envirenment. Or, if you like, change the app flow so that it starts, but works with major disabilities, if not launched on Android.
  • use obfuscator like secureSWF or SWFEncrypt

Personally, I use secureSWF but there are plenty of them -- choose to your liking.


The Capabilities.os isn't highly reliable, as a linux user could view it in a web browser / desktop (My HTC androic reports Linux OS).

As far as I've seen, version is specific to the player version and should always report "AND [version string]" - example "AND 10,2,150,60"

if( flash.system.Capabilities.version.slice(0,3).toUpperCase() != 'AND' ){
    // ....oh noes! hide and destroy everything!
}

P.s. I +1'd you scriptocalypse for flash.system.Capabilities :)

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html#version

It's been around for a while (see player 9 / air 1.0 / etc) and is defined in the API ref, so its not just a hack

version property
version:String [read-only] Language Version: ActionScript 3.0 Runtime Versions: Flash Player 9, AIR 1.0, Flash Lite 4 Specifies the Flash Player or Adobe® AIR® platform and version information. The format of the version number is: platform majorVersion,minorVersion,buildNumber,internalBuildNumber. Possible values for platform are "WIN", ` "MAC", "LNX", and "AND". Here are some examples of version information:

 WIN 9,0,0,0  // Flash Player 9 for Windows
 MAC 7,0,25,0   // Flash Player 7 for Macintosh
 LNX 9,0,115,0  // Flash Player 9 for Linux
 AND 10,2,150,0 // Flash Player 10 for Android
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜