Typically, in a PHP setup, you can simply use
include('includes/myphpfile.php');
to incorporate seperated parts of PHP code and / or HTML markup. Now when it comes to Flex 4, I’m not quite sure how I’d go about doing that same thing, only this time, for ActionScript files. I want to do this kind of approach since my source code gets really annoyingly huge as the Flex app I’m developing grows. That’s why I want to separate it into small chunks to avoid getting myself overwhelmed with too much code to see at a time.
I strongly recommend you learn about building Flex Components. That is the preferred method of encapsulating code and breaking up a single ‘file’ into multiple components and you’ll thank yourself in the long term for learning those skills.
The answer your posted can help you move ActionScript to a different file:
But it is not the same as building reusable encapsulated codee. You can also use the include directive to accomplish the same thing:
The include directive can be used in ActionScript components / classes too, while the Script source attribute is MXML only.
That said, relying on the include file is often considered a crutch and is not a decision I would take lightly.