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.
9for 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.
0for version 9.0 r28. ${version_revision}- The revision number of the version of Flash that is required to run this app, e.g.
28for 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
.swfextension, e.g.MyApporMyApp-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
backgroundColorattribute of the<mx:Application>tag, or, in the case of ActionScript-only projects, in thebackgroundColorfield 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 thebackgroundColorandbackgroundGradientColorsattributes of the<mx:Application>tag. ${width}- The width of the application, as specified in the
widthattribute of the<mx:Application>tag, or, in the case of ActionScript-only projects, in thewidthfield 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
heightattribute of the<mx:Application>tag, or, in the case of ActionScript-only projects, in theheightfield 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
pageTitleattribute of the<mx:Application>tag, or, in the case of ActionScript-only projects, in thepageTitlefield of the[SWF]metadata attribute of the main application class, e.g.[SWF(pageTitle="flex r00lz")] public class MyApp extends Sprite.
Comments(11)
This is a good reference, thanks mike
Glad to see a compiled list in a clean format. I’d imagine the Flex Docs don’t have a page like this, right? :)
[...] 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 [...]
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!
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.
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!
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.
never mind, found it on http://www.morearty.com/blog/2006/05/23/flex-builder-ctrl-click-to-access-a-lanch-configs-properties/
[...] also: http://livedocs.adobe.com/flex/3/html/help.html?content=metadata_3.html Available macros in html template files About this [...]
[...] 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/ [...]
If you want better control of variable substitution or template interpolation, consider using Maven FlexMojos… it all becomes arbitrary then.