Macros that are available in html-template files

In a post last month, I briefly mentioned the list of macro substitutions that are available in the files in the html-template folder. Here, I’ll offer a little more information on those. I’ll try to make sure this makes it into the next version of the documentation.

${project}
The name of the project, e.g. MyProject.
${application}
The name of the application, e.g. MyApp.
${version_major}
The major version number of the version of Flash that is required to run this app, e.g. 9 for version 9.0 r28. You can change this and the other ${version_...} macros by going to Project > Properties, then “Flex Compiler” or “ActionScript Compiler,” and then changing the player version number in the “HTML wrapper” section.
${version_minor}
The minor version number of the version of Flash that is required to run this app, e.g. 0 for version 9.0 r28.
${version_revision}
The revision number of the version of Flash that is required to run this app, e.g. 28 for version 9.0 r28.
${build_suffix}
This is equal to "-debug" when building the debug version of the SWF, and "" when building the release version.
${swf}
The name of the SWF, not including the .swf extension, e.g. MyApp or MyApp-debug. This is essentially a convenience macro which is equivalent to ${application}${build_suffix}.
${bgcolor}
The background color of the application, as specified in the backgroundColor attribute of the <mx:Application> tag, or, in the case of ActionScript-only projects, in the backgroundColor field of the [SWF] metadata attribute of the main application class, e.g. [SWF(backgroundColor="#ffffff")] public class MyApp extends Sprite (see this post for more information on setting the width, height, and background color of an ActionScript project). The result is in the form #rrggbb, e.g. #ffffff. This can actually be a little tricky to use, because by default, the background of a Flex app is actually a gentle gradient from one color to another; if you want the HTML background to match the background of your Flex app, you may need to fiddle with both the backgroundColor and backgroundGradientColors attributes of the <mx:Application> tag.
${width}
The width of the application, as specified in the width attribute of the <mx:Application> tag, or, in the case of ActionScript-only projects, in the width field of the [SWF] metadata attribute of the main application class, e.g. [SWF(width="300", height="400")] public class MyApp extends Sprite.
${height}
The height of the application, as specified in the height attribute of the <mx:Application> tag, or, in the case of ActionScript-only projects, in the height field of the [SWF] metadata attribute of the main application class, e.g. [SWF(width="300", height="400")] public class MyApp extends Sprite.
${title}
The title of the application, as specified in the pageTitle attribute of the <mx:Application> tag, or, in the case of ActionScript-only projects, in the pageTitle field of the [SWF] metadata attribute of the main application class, e.g. [SWF(pageTitle="flex r00lz")] public class MyApp extends Sprite.

11 Comments so far

  1. Renaun Erickson on January 24th, 2007

    This is a good reference, thanks mike

  2. Chris Charlton on March 6th, 2007

    Glad to see a compiled list in a clean format. I’d imagine the Flex Docs don’t have a page like this, right? :)

  3. [...] by Adobe, but Renaun Erickson’s posting together with Mike Morearty who nicely documents the marco’s. If you’ve got this far, you need to consider added your FlexUnit’s to [...]

  4. Josh Adams on July 31st, 2008

    It took me about forever’s worth of searching, both in Flex Builder’s Help and on the web, to find this info! Thanks! If you ever need any ColdFusion info, hit me up!

  5. Matt Hayes on September 23rd, 2008

    I really appreciate this list of the available Macros, it’s super helpful… thanks.

    I’m curious though, if it would be possible to create my own macros… or if there’s another (automated) way to get information about the project/application/etc.. into an HTML doc.

    Thanks again for the insight.

  6. mike on September 23rd, 2008

    Matt, no, there is no way to create your own macros, and there is no other automated way to get other stuff into the HTML doc.

    If you have a specific use case in mind, please log an enhancement request at http://bugs.adobe.com/flex, along with the use case. Thanks!

  7. Jordi on October 20th, 2008

    Just wondering, once the file is named index.html instead of MyApplication.html, how am I able to run it from flex? Cause it keeps looking for MyApplication.html, and I don’t want to rename my main class.

  8. Jordi on October 20th, 2008
  9. [...] also: http://livedocs.adobe.com/flex/3/html/help.html?content=metadata_3.html Available macros in html template files About this [...]

  10. [...] Mike Morearty, developer of the Flex Builder team listed all the macros available in Flex Builder here: http://www.morearty.com/blog/2007/01/24/macros-that-are-available-in-html-template-files/ [...]

  11. Darren on January 20th, 2010

    If you want better control of variable substitution or template interpolation, consider using Maven FlexMojos… it all becomes arbitrary then.

Leave a reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word