I think we don't understand each other, I don't use the package name like a web address...
I load swf 2 in the same ApplicationDomain than swf1 with a Loader :
loader.load(new URLRequest("http:///mydomain.com/the-address/swf2.swf"), new LoaderContext(false, ApplicationDomain.currentDomain));
Then swf 2 can access all the classes in the ApplicationDomain (swf 2 classes and swf1 classes), for example :
I tried to embed the code of com.common.MyClass both in swf1 and in swf 2 but then swf 2 is too big, so I would prefer to embed it just in swf 1 and have swf2 access the classes in swf1.
Can you explain "load all your project with php from a middle layer" ?
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.
What do you think about embedding swf2 in swf1 ? so that swf2 code is protected and I can load only one swf from the fast CDN address. That way I don't need PHP checking rights.
If swf2 is embedded in swf1, a decompiler could not show swf2 code ?
Anyway, this would not solve my completion / type checking / function signature checking problem.
@sinious : I don't use Flash Pro but FlashBuilder, I don't know what is a frame script, I'm not sure to understand what you suggest. Let's say I have a pure AS project named SubApplication, with the main class named SubApplication, and other AS classes. I would like that all those classes have auto completion, asdoc, type checking, etc. on swf1 classes that are in MainApplication/src.
If I add MainApplication/src in the source path in the properties of SubApplication project, I will have completion etc. but then MainApplication classes will be embedded in swf2 and swf2 size will grow too much.
Is that what you suggested ?
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?
I use svn.
Maybe I could add the code to the source path temporarily, and try to remember to remove it (and all the imports automatically included) before I export the swf, if it's the only solution...
About protecting swf2 : do you think that embedding swf 2 in swf1 will protect (as much as possible) swf2 from decompilers ?
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.