Flex: Reuse classes for multiple projects without copy+paste? - apache-flex

OK I have a few classes I have made or found on the web that I plan to use in multiple projects, I would rather store these classes in a central location instead of copy+pasting them into each project.
my Flex projects have their own workspaces inside the path Flex/WorkSpaces/< workSpaceName >
If I wanted to put another folder inside the Flex directory and have the packages be com.mydomain.whatever
What folder structure would I need to make, and how would I make the code accessible to my projects?
Thanks!

You can import entire projects in FB3. Take a look at the documentation.
It is always better to use packages. Keep the src organized as follows:
com
|__ johnisaacks
|_____ utils
|_____ components
|____ video
|_____ assets
....

Go into the Project Properties, Choose Build Path. In the Source Path tab, you can add folders containing ActionScript files from anywhere on the file system. In the Library Path tab you can add individual SWCs or folders containing multiple SWCs.
An example (for Windows, but it should be similar on a Mac):
Let's say you have a folder C:/Development/classes where you keep all the "shared" source files that you reuse across projects. In that folder, you want to keep one of your classes, com.example.MyClass. You should use this folder structure:
C:/Development/classes/com/example/MyClass.as

What I would normally do is create a new library project and store those classes in that project.
To link that library project to your current project you would only have to add it to the library path of the current project (Project Properties -> Flex/ActionScript Build Path -> Library Path tab).

Related

Where do I put my skin files for a desktop libgdx project

I'm using libgdx for a desktop game/prototype and I want to start getting into UI design.
I followed the answer here: Default Skin LibGDX? to download the necessary skin files but I'm not sure where in my project to put the ui directory with these files. I have tried to put it right in the project directory along side libs and src, so there's libs, src, ui, Referenced Libraries, and JRE System Library but when I reference the Skin with new Skin("ui/uiskin.json") it is throwing a filenotfound exception. Should this be down in my com. package in the project viewer in Eclipse?
I understand for an Android app you use the asset folder, but I don't have one in my project since it's a desktop app, even if I were to just add it.. I still don't know at which level unfortunately. This is probably really simple.
Thanks in advance.
The skin files are being looked up as "internal" files. On Android, this will look through the Android asset directory and CLASSPATH, but with the Desktop backend, only CLASSPATH will be searched.
To be consistent with the way things generally work in Libgdx, create a directory called assets next to the src and libs directories in your desktop project. Then put your ui directory inside assets. This isn't strictly necessary (see below) but will make your project a bit more compatible with other Libgdx code and projects. With an Android project the desktop assets directory is normally linked to the Android assets directory, but without an Android project you should create a regular directory.
If you used the Libgdx Libgdx "setup tool" the desktop project's assets directory should already be on the CLASSPATH. If not, you will also need to add this assets directory to your CLASSPATH: Right click on the project -> Properties -> Java Build Path -> Source tab -> Add Folder ... -> Select the assets directory.
To be clear, if you don't want to mirror the Libgdx conventions above, you just need to make sure the directory containing your skin files is on the CLASSPATH, then they will be found as "internal" Libgdx files (for example, you could add the ui directory directly to the CLASSPATH, and then look the files up without the explicit ui/ prefix).

Flex and Ant: How do I include other folders via ant script?

I currently have a Flex project that was done in Eclipse, using the following compiler settings:
Flex Build Path: (Source Path) includes source folders from other areas, i.e common_components, which aren't projects on their own but just folders with various code I need to share. This works fine but I want to migrate to using ant.
I have read in places on how to include libraries, via compiler.include-libraries, but as this isn't a library but rather just bunch of folders with .as and MXML files, how do i accomplish this?
You want to look into adding source paths so that the compile can look at more than one place for your classes. You can do that by adding new compiler options.
The compiler option you're looking for is source-path path-element [...].

where to put library folders relative to ActionScript project in FlashBuilder?

If I create a new ActionScript project with Flash Builder and want to add some library (for example Tweenlite) where do I have to put the gs folder of Tweenlite relative to my project folder? and what do I need to setup in the project settings in order to be able to use it?
Doesn't matter, where to put your library folder. Just set the path to this folder at Project -> Properties -> Flex Build Path -> Library Path -> Add SWC Folder...(or Add SWC)
I would recommend that you create a new Library project named something like 'TweenLite' and dump the files in there. Then in Flash Builder go to:
Project -> Properties -> Flex Build Path -> Library path tab -> Add Project -> select the tweenlite project.
In this manner the project's source only gets compiled when it needs to be and the resulting swc is used by your application. You still get the benefits of the go-to source hotkey and can set breakpoints in the tweenlite project as well.
Cleaner, reusable, faster, it's how I do things.
*Ah also, multiple projects can reference the tweenlite library project now instead of having to copy & paste the code everywhere.

adobe flex: 2 projects with same class, can i share that class between the two projects?

i have several flash projects and i have common classes. is there a way to share these classes between the project so i won't need to copy it to all the project when ever i modify something?
In Flex Builder, right click on the project and choose properties. In the Flex Build Path section choose Add Folder... and pick the project you want to reference then the /src folder (so ${DOCUMENTS}//src). This will allow one project to use the classes in another project. However be careful as this will slow down compile times. Probably a better idea to build a library where you have dependencies.
in adobe flex/flash builder when i add a new folder, i can click on advanced and then i can choose to which folder, this folder will be linked. by doing so i can share directories between several projects.

create .project file for flex application

I want to add my flex project to a SCM like Clearcase and then allow other developers download it and use in FlexBuilder.
What foramt do i need to place it in my clearcase so users can simply download and import into Flex Builder? Is there some way to create a .project file or similiar to allow Flex Recognise the project in clearcase?
I do not know Flex Builder project config files (I do know very well ClearCase though), but this question looks like "Do you keep your project files under version control ?" or "Which eclipse files belong under Version Control"
In essence, you should put any config file in ClearCase as long as you have relative path and/or variable for the other users to interpret.
A snapshot or dynamic ClearCase view will simply present those files for them to use, whatever they are. For instance, some eclipse .project or .classpath can be stored that way, while using linked directories.
So for Flex Builder project, one way to determine what file to store is to copy a minimal subset of those files in a new directory and check if you can re-open your project successfully.
Once the minimal set of file is determined, you can "add to source control" them.

Resources