Skip navigation
Currently Being Moderated

Use classes in another project, without including them

Jul 30, 2012 9:38 AM



I have a full flash website that is ok. One part of the code is technical and the result of months of R&D, we would like to try to protect it from decompilers. Biggest part of the website is no need to protect but we want it to download fast.

We would like to split the AS project into 2 projects :

- swf 1 we put it on a caching CDN so that it loads fast (it's big, with some medias)

- swf 2 we want to protect, must be as small as possible because it will load slowly. The server checks the rights before it returns the swf.

- some classes are used by both projects

How would you do that ?

What I think now :

- swf 1 (the big fast) has the classes used by both projects. It loads swf 2 (the small protected) with a Loader. The URL we give to the Loader executes a PHP script which checks the rights before returning swf 2.

- swf 1 can access functions and variables from swf 2 classes BUT without auto complete, type checking, function signature checking... The 2 projects can communicate by Events.

- swf 2 can access the common classes in swf 1 :


var MyClass:Class = ApplicationDomain.currentDomain.getDefinition("com.common.MyClass")


But same problem, we don't have auto complete on variables and functions from MyClass, no ASdoc, no type checking, number of arguments checking...

To fix this, I can put the common classes in a 3rd project. I import this project 3 in project 1 and project 2. The code isn't duplicated, no problem to maintain it, but it is compiled in both projects and then swf 2 is too big.

I hope I explained it clear enough... If you figure out my problem, I'm listening !

  • Currently Being Moderated
    Jul 30, 2012 9:55 AM   in reply to eprevot123

    "com.common.MyClass" this is not a path, all the imported class file are embeded into the swf, you can't use it like a web address.


    The opcion is load all your proyect with php from a middle layer

    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 7:12 AM   in reply to eprevot123

    As far as I read from your initial concern, you seem like you really just want the code completion to work. Is that true? If so, you mention one SWF has "all the code" you want to use in another SWF. Does the SWF with the code compile from external .as files or did you actually put the code directly into the SWF in a frame script?


    If it loads from external AS files then simply set your projects "source" folder to read code from the same place the SWF with "the code" reads it from and auto-complete will work. You may access your classes how you're mentioning and code completion will (annoyingly) add in import statements for you, but you can simply delete those when you're done coding all at once.


    Whenever you're talking about software, obtaining the ultimate desire, something unhackable, just isn't feasible. You'll have to accept that. How you're doing it now is probably fine. The best you could do is encrypt and decrypt all transmissions on both ends and even internally as memory and http requests can easily be intercepted and read plainly. But I assume you're trying to keep the typical person out.

    Mark as:
  • Currently Being Moderated
    Aug 1, 2012 10:26 AM   in reply to eprevot123

    Yes in the flash builder project just adding in the source path in project properties was what I meant. You can do it temporarily just for completion, then remove it before a build.


    I tend to use a repository so I don't mind copies of code as updating and deleting them is trivial. Are you using a github or svn?

    Mark as:
  • Currently Being Moderated
    Aug 2, 2012 6:58 AM   in reply to eprevot123

    As much as the stock offerings go all you can do is tick off "Protect from import" but that's not geared toward a decompiler as much as importing into a flash project. I'll have to conceed to the long held wisdom that if someone wants something bad enough, they'll get it. Nothing is hack proof. Embedding the SWF in another SWF won't make a difference, just a larger bowl of spaghetti to sift through.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points