1
votes

I have inherited an Actionscript file from an old project and I've been told that it's possible to generate a SWF from it, though I don't have a corresponding FLA file.

The code within the file follows this form:

package {

    import flash.display.LoaderInfo;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    // additional import statements

    [SWF(width="640", height="480", frameRate="30", backgroundColor="#FFFFFF")]

    public class MyClass extends Sprite {
        // code, code, code
    }
}

I have tried bringing this into Flash Builder and using "Run as Web Application" but I get a bunch of errors I don't understand (calls to undefined methods, definitions that can't be found).

I have done quite a bit of AS2 coding but not so much AS3 and zero Flex. I'm not sure if I am just not up to date on some of the latest methods for compiling SWFs without a corresponding FLA.

Is there a way to compile this type of file into a SWF? Or am I going about it the correct way but possibly just missing some dependent files?

1
You're omitting a lot of the important info we need to see. Add the rest of the imports back in and show us the errors you're getting.redhotvengeance
You're likely missing some dependents, eg, the files that go with the addional imports that don't begin with flash./fl./mx.BadFeelingAboutThis
Thank you for the responses. Unfortunately I cannot add the rest of the imports because they are proprietary, but I trust that you are probably correct. I guess what I am looking for then is confirmation that if I indeed had all the dependencies in their proper place, that I Flash Builder would produce a SWF for me. That is, is Flash Builder a tool that can create a SWF from only AS files - no FLA?bergie3000
@bergie3000 That is correct. If the additional code isn't in the source folder, it should be 'linked' from Actionscript Build Path (Source path for .as folder/files or Library path for .swc files) .George Profenza

1 Answers

1
votes

Is it possible to generate a swf from an .as file without the original .fla:

Yes, IF you have all the dependencies.

When using flashBuilder, and you look at all your imports, anything that doesn't start with flash. or mx. is another file you'll need. This includes all imports within those class files as well.

Also, many .fla's use display objects that are in the library. If this is the case, those would need to be exported to another swc/swf and then linked/loaded to your flashBuilder project. That includes components (the 'fl' package).

So to sum it up:
If the original.fla is just an empty project with a document class linked, then you'll be fine if you have all the needed class files that are imported.

If the original .fla has library assets that are linked or dropped onto the timeline, then you will have issues if you can't get the original .fla.


How To Do This In Flash Builder
In flash builder, create a new ActionScript Project.
Put all the dependent files in the src folder of the project it just created - keeping their folder structure/hierarchy (the package name represents the folder it expects the .as file to be in relative to the src folder).

In the tree view, find the main .as file (documentClass), right click and tell it that it is the default application file (if you want, you can delete the file that was automatically generated when you created the project - projectname.as).

Run the project and it will put the swf in the bin (or bin-debug) folder with the same name as the project.