Adding Flex Modules - apache-flex

Is it possible to add multiple Flex Modules at a time to be built in a project as opposed to adding them one by one, as this is becoming a very tedious task.
This is for both Eclipse and Flash Builder 4

You cannot add multiple modules through Flash Builder as far as I'm aware. The dialog is only for one-at-a-time.
You can, however, add them yourself via the .actionScriptProperties file located in your project's root folder (you have to browse via explorer to see it).
Under the <modules> node, add as many of the following elements as needed:
<module application="src/YourMainApp.mxml" destPath="com/modules/yourModule.swf" optimize="true" sourcePath="com/modules/yourModule.mxml"/>
The destPath determines where the module will be located in the published directory structure. The sourcePath is the path within your project to your module's MXML file. Both of these are relative to the main app's location.

Related

Embed external CSS in Flex's swf file

I want a few Flex (SDK 4.6) applications to share the same stylesheet (stored in CSS file). However I do not want to distribute standalone file along those applications' SWFs, but rather want to embed the CSS file into Flex application file (just as you embed images etc.). CSS declarations include font-embeddings so it is (I think) impossible to load CSS at runtime.
What I already found out:
I cannot simply use <fx:Script source="#Embed(stylesheet.css)" />. Wrong syntax.
I cannot use inline stylesheet in some MXML component that is shared among applications because CSS contains type declarations which are not allowed in components.
I can choose to compile CSS to SWF but this creates standalone SWF file (so I can embed Flex framework into SWF but not a standalone CSS ;]).
I hope I am missing something obvious and this is fairly easy to achieve.
Create a library project (producing a swc file)
Add the stylesheet as a resource
Put this project (or the compiled swc) on your other project's build path
You can now use this resource from within your other projects:
<fx:Style source="stylesheet.css" />
As an example:
In the librabry project you have src/stylesheet.css
If src is a source folder, the file should automatically be packaged into the library
If it's not, you'll have to manually add the files: in FlashBuilder this can be done through the Assets tab of the Build path editor. On the command line, add it with the -include-file option.
An alternative to using the swc as a library dependency, is to define it as a theme dependency. In FlashBuilder there's a Theme wizard in the project properties. On the command line do:
mxmlc -theme="/path/to/my/theme.swc" MyApp.mxml
If you use it as a theme, you don't even have to include the fx:Style tag in your Application. The CSS is included by default. But I think it has to be named defaults.css.

how to convert a mxml file to a compoent that i.e .swc file

hi i hav tried to covert .mxlml to .swc file using flex builder
it's not working when i integrate with other application...can any one say how to get .swc using SDK...pls i need very clearly
In Flex Builder (Or Flash Builder) you need to create a Flex Library project. Put that mxml file in the library project, right click and select "include in library" from the context menu.
The Flex Library project should generate a SWC with that class which you can then use in other proejcts by adding that SWC to the library path.
Flextras is right, but a little more clearly (since you haven't accepted it yet):
Within Flex Builder (I'm assuming Flex Builder 3, but it's probably the same in Flash Builder), go to File -> New -> Flex Library Project. Enter a name an click Finish. This creates your project.
Create (or copy) the files you wish to compile into the src folder in your new project. The trick is that when you copy a file to the src, it is NOT automatically included in the library's build, and hence it will NOT end up compiled in the resulting SWC.
To include these files in the library build, right click on the project in the Navigator panel and select Properties. Click on "Flex Library Build Path" on the left, and under the "Classes" tab on the right, click "Select All" (or check the boxes you wish to include manually).
Once your files are included in the library project's build path, simply build the project. The build should happen automatically, but you can go to the Project menu and select "Clean" to be sure. Ensure that your project compiles correctly (no compile errors), and a SWC file should be generated in the bin folder. Note that pretty much whenever you change anything within the project's file structure, you will probably need to repeat the step of clicking "Select All" in the library build path.

How to exclude files from being copied to bin-debug on build

Using Adobe Flex Builder Pro stand-alone, how do I filter or exclude some files in my project source folder from being copied into the bin-debug folder during a build? Flex Builder is based on the Eclipse platform IDE, this could be as much of a question about Eclipse as it is Flex Builder.
You can prevent Flex from copying all extra files like this:
Within Flex Navigator panel, right-click on the Flex project
Choose Properties
Click on "Flex Compiler" on the left
Under "Compiler Options" DESELECT "Copy non-embedded files to output folder"
Click OK
If you want to include some but not others, then you can use a custom Ant build script to do the build and copy the limited files you want to copy.
Eclipse allows you to specify include and exclude patterns on the Java build path. The following describes how to exclude files from the Java path, there may be an equivalent on the Flex Build Path properties page.
Update: This is how it is done in Java, I imagine that the Flex Build Path would implement it in a similar way if at all. As someone has kindly voted me down for saying that it might be done this way it appears that this is not supported in Flex.
Open the project Properties (right-click->Properties or Alt-Enter)
Select Java Build Path and the Source tab.
Expand a source folder and select the Excluded: child item
Select Edit...
on the dialog, you can then specify one or more glob patterns to exclude files from the path
If you want to exclude specific resources but still include non-embedded files you can add a Resource Filter.
Open the project Properties
Select Resource > Resource Filters
Add a Resource Filter by clicking Add... on the right
Set Filter type to Exclude all
Set Applies to to Files and folders and select All children (recursive)
Specifiy the File and Folder Attributes (i.e.: Name matches ".git")
Click OK and then Apply to save your new Resource Filters.
Clean the project by going to Project > Clean... and clicking OK
This process can also be used to create an "Include Only" resource filter, essentially white-listing instead of black-listing.

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