Code organization (multi files) in AS2

4 posts

Flag Post

Ok, I feel that this is very basic, but I’ve been having problems finding out how to do it (and yes, I’ve googled quite a bit). Basically, my actionscript is getting unmanageably large. I feel certain that there is some sort of “import” command that would allow me load an external .as file (though not one that’s a class – just some scripts). Please tell this can be done – I’m getting a headache scrolling through all this crap. Thanks in advance! :)

Flag Post
#include ""

Is what you want. Note that because its a # directive, you don’t put a semicolon on afterwards.

Flag Post

Oh, bloody hell. I was using a semi-colon. You called that one perfectly. facepalm Thanks for the help! Now I can finally read my code again! :)

Flag Post

for further organization, you can stick the .as files in a folder in the same directory as the fla and by using the import command


Flash Programs

where Flash programs and SecondSetofCodes are folders, is automatically loaded since it’s in the same folder as the .fla file, but for the other two:

import SecondSetofCodes.AScode02;
import SecondSetofCodes.AScode03;

is all you need to do, although I’m sure a simple import SecondSetofCodes; will be just fine.