How to create a library with shared code in ActionScript 3? - actionscript-3

Say I want to create a library.swf file that will contain most of the definitions for images, sprites and (most importantly) code for custom components, that will be used by other sub projects by only linking the library.swf asset without actually importing anything in the resulting SWF file.
Here is the naive way I tried with Adobe Animate:
Create library project.
Create scripts needed.
Add scripts to project files without specifying main script of the main scene.
Expectedly, last step caused troubles because nowhere in the application I see a way to add scripts. The most promising is Library tab where I can add New Symbol..., but I would think I don't need to create MoveClip for every script I want to add.
In the meanwhile I was trying to find a way I could use this library in other projects, which I believe must be done by importing assets, but the same problem again - I can't find a way to import/reference some SWF file from which I can import packages.
Do I need some other IDE, say FlashDevelop, or is there a way inside Adobe Animate I totally missed?

Related

Creating and Using a SWC File - Flash AS3

So I'm really confused on how to create, and use, a SWC file. I understand that a SWC file can be created to hold multiple assets. Basically, my code setup is the following:
c_Test.as - all testing of classes/fla files is done here
c_Test.fla - contains a few visual objects used/tested in c_Test.as
Class.as - class referenced multiple times in c_Test.as
Class1.fla - contains an important bitmap that is loaded into c_Test.as
So what I need to do is create a SWC file to be used in other projects; this is going to be the base of a multitude of other large projects, and I don't want to have to continuously copy and paste code into different folders. I am using Flash Builder 4.
So far, I went to publish settings in Flash CS6 in my c_Test.fla file and checked off Export SWF and Export SWC. What does this do? Has this created my SWC file?
I need to be able to access, from any random project, both Class.as, and Class1.fla.
Edit
So to clarify, cw_Test.fla is just a testing copy of the actual main fla file. I don't need this included in my swc. I just Exported my Class1.fla to SWf and SWC, and set a library path to the folder containing Class.as. Is this all I need to do to access both of these files from any project? (Besides importing them into any file I need them in).

Flash Builder 4.7: How to force the compiler output the resulting swf in particular folder

We're developing a game and the project is well separated and structured. There are projects for different kind of things, such as UI, main-logic, gameplay, etc. Just how it's supposed to be.
Now, the main app project (that runs with Flash Player), uses a folder that is called assets.
I want one of the other projects (the Logic project) to be able to output in "assets/logic".
To do so I first tried (in the Logic project) with including the parameter -output in the compiler settings, but FB rejected it.
Then I tried to set the Output folder from ActionScript Library Build Path menu. I managed to set it to that folder, but it just outputs a SWC file, called just like the project is, and I just cannot force it to generate a swf file with a name I specify. That sucks.
Furthermore, I'd like to force the Logic project to compile itself and generate into that folder before the main project does, so that it includes that latest from the Logic project.
So how do I achieve these things?

Actionscript 3.0(Adobe Flash CS4) Loading external .as files without knowing name of .as file

I want to know how to load external class files(.as files) in actionscript but don't have to know the class file's name. Think of it like loading mods in minecraft with forge mod loader, it doesn't know the main class of the mod's file name, yet it successfully loads the mod. I want to know if something like this is possible in actionscript 3.0 because I feel like making a tower defense game that isn't like the others out there but have it so it can be modded and have mods loaded but of course I have to load the class file without knowing the class file's name.
Note: I don't got access to Adobe Air so I can't use anything that requires Adobe Air.
You want to load a particular .as file AFTER or BEFORE compilation? After the compilation it is hardly possible - the file would not be compiled and therefore it would be useless. Why don't you use a swf or some kind of XML/JSON with settings in that case? Before the compilation you would still need to identify it by it's package name/name.
Basically, you want a plugin management system.
In AS3, it is not possible to "load" a .as file on execution, because it is a (uncompiled) source file. But, it is possible to load another swf and to use the classes within it.
Your process should probably be something like this :
Get a list of the plugins/addons. If you were using AIR, it would have been possible by browsing the content of a folder. Since you're not, you'll probably need to use a listing file (basically, a file that say "Here's the list&path of the plugins you need to load".
Load each swf file
(possibly) call a initialization method for each plugin.
You may wish to look into the way OSMF manages plugins, for example : http://osmf.org/dev/osmf/OtherPDFs/osmf_plugin_dev_guide.pdf

How to I keep track of changes in FLA file (via version control)

I have all of my files in version control (SVN subversion). FLA file is not a text file, so when I change it and check it in, there isn't a way to see what has changed inside of FLA.
Is there a way to keep track of changes to FLA file and it's contents?
Flash CS5 has introduced a new file format called XFL which has been designed for use with version control systems. This format basically splits up your FLA file into a series of separate XML data files (all contained within the one folder) which means version control systems can accurately determine what parts of the file have changed.
Simply go to File > Save AS, and select xfl from the drop-down list.
If you're using anything before CS5, then unfortunately there is no similar way to accomplish this task. I will add, however, that if this is the case, then you can try and mitigate this problem by keeping all your code in an external AS file and load any data from external xml/image/etc. files. This way, there is at least some degree of tracking for certain parts of your project.

Compiling as3 project to swc file in flashbuilder

i have a question and i'm hoping to find an answer here,
i created a flashbuilder project that contains some classes with functions that i use often,
i have around 6 classes, would it be possible to compile these classes to a swc file so i just have to add the swc in a new project to access them?
Or isnt it possible to create swc's with flashbuilder?
Maybe i could do it in flash but dont have any idea how to compile multiple classes into 1 swc. file.
Sorry if this is a stupid question but ive never used it before and couldnt find much about is.
Inside FlashBuilder create a new "Flex Library Project".
It will take you through a new project wizard that is similar to an Actionscript Project. Once it is created, you can add your .AS classes to the source folder. As long as Project->Build Automatically is checked, it will automatically create (and update) a SWC file in your designated output folder, usually (/bin).
If you want to pick and choose particular classes or include external libraries, SWFs, or other SWCs, select Project->Properties->Flex Library Build Path there is a tab called "Classes" where you can select which classes you want exported into the SWC.
You can just create a library project for this.
Move all of your code into this project and build the project.
The output will be a .swc file in the bin directory.
You can also do this from the command line using the compc (short for component compiler) and incorporate it into an ANT task or a Maven build.
Cheers