Tag Archive for 'Embed'

The easiest way to protect your code

I heard on Russian twitter that flash decompilers fail to parse embeded binary data (for example another SWFs). Tested it locally and that rendered to be true — the content of embeded SWF was impossible to extract. That seemed so simple yet effective. Just use something like

[Embed(source="swf.swf", mimeType="application/octet-stream")]

Someone could write a simple command line script to split SWFs into several parts to embed them inside a loader SWF and assemble again. Or it’s possible to add simple encryption to go further.

This idea is indeed very simple so someone might have made a tool like this already. I didn’t find a tool but I did find a post about this technique. And since then I successfully used it in one of my projects.

Importing assets

Separating graphical/sound assets and actual logic is a very good practice. It allows to avoid a lot of problems. For some time I’ve been using compiled SWFs with ActionScript skin classes embeding symbols from that SWF using [Embed] meta tag. But recently I came across much better solution using SWC.

So the algorithm is the following:

  1. Create a new AS project in Flex Builder.
  2. Create a new FLA at ‘assets/assets.fla’.
  3. In Publish Settings of that FLA set ‘Export SWC’ checkbox.
  4. Create and export assets via ‘linkage properties’ as something like ‘assets.MySymbol’.
  5. Publish SWC.
  6. In Flex Builder add this SWC at Project -> Properties-> ActionScript Build Path -> Library Path -> Add SWC.
  7. Now in Flex Builder we can import and use assets.MySymbol and IDE knows about it and its type.