Change mxmlc from swf to html on ubuntu - apache-flex

When I use mxmlc to compile my mxml file, I get swf file. Now, I want to change the config to make mxmlc compiler generate html file instead, as we can do in Eclipse or Flex Builder. Any solution? Thanks!

You can't do this. From the documentation:
The mxmlc command-line compiler does
not generate an HTML wrapper. You must
create your own wrapper to deploy a
SWF file that the mxmlc compiler
produced. The wrapper is used to embed
the SWF object in the HTML tag. It
includes the <object> and <embed>
tags, as well as scripts that support
Flash Player version detection and
history management.
Of course, the HTML wrapper is pretty much all boilerplate, apart from the name of the .swf file it wraps. You could create one for a project at the beginning by copying an existing one and changing the .swf-file reference, and that should be good enough most of the time.

You should use an ant task to build your project. Flex Ant tasks include a html-wrapper task that generates that html. See "Using the html-wrapper task".

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.

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 [...].

How to create an SWC file

All I want is to take my AS3 source code files and compile them into a SWC file.
Upon inspection, the SWC files I generate end up with some kind of timeline or spite in them when I use the Flash IDE or that Flex SDK utility "compc", and it's irritating.
Flash is timeline based; so everything in Flash uses a timeline. They hide it very well in Flex, though, so it's not obvious under the hood.
To create a SWC file in Flex, you need to use the command line compiler, although it sounds like you've already done that, so I'm unclear what your issue is.
In fact, you can build a "flex library project" in Flash builder. place your AS3 source code files in this project, it would automatic generate a swc file in which your AS3 Class;

Compile a Flex CSS file into a SWF using the command line

I understand that in Flex builder we can right click on a CSS file and choose 'compile to swf' and our CSS SWFs will automatically be compiled along with the main app.
Is possible to compile the CSS file only (not with the main app) from the command line?
I want to :
Give clients a Flex CSS file to hand edit
Allow them to upload the file via a CMS
Trigger a server process to run the compiler from the command line, outputting the compiled SWF to the appropriate server path.
This would of course be a whole lot simpler if Flex properly supported text-based CSS files (without requiring manually applying styles using AS3).
Yes, it is possible and really easy just type:
mxmlc yourFIle.css
at the command prompt

Why does Adobe Flex strip ActionScript from Flash embed symbols when compiling?

I wanted an animation to dispatch custom events as it cycled. It became apparent that not even trace() was running. After some searching, I found the following at Adobe:
http://livedocs.adobe.com/flex/3/html/help.html?content=embed_4.html
"If the SWF file contains any ActionScript code, Flex prints a warning during compilation and then strips out the ActionScript from the embed symbol. This means that you can only embed the symbol itself."
I also found a work-around by Grant Skinner at:
http://gskinner.com/blog/archives/2007/03/using_flash_sym.html
So, I can proceed, but I'm still wondering. Why does mxmlc strip ActionScript from Flash compiled resources when embedding their symbols into Flex apps using metatags?
Sorry for the very late response, but since I wrote that code, I can answer. :-)
Basically, there are two answers.
For old SWF assets that contain AS2 bytecode, it was far too much work to try to convert the bytecode to AS3. I'm assuming this isn't theuse case you care about anyway.
For SWF assets linked to AS3 bytecode, the basic problem is that there is no dependency information any more, so when we clone the asset, we have no idea what else we would need to pull. Because Flash can export a SWC, I decided that this was a far more robust workflow for getting assets with code from Flash to Flex. (Take a peek inside a SWC file, and you'll see an XML file that describes the dependencies used by the linker.)
It's probably a performance issue. To load a swf resource without stripping it, load it dynamically using SWFLoader or Loader instead of embedding it.

Resources