Navigation

Previous

Archives

2007年9月28日 @ 14:42

Macros that are available in html-template files

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.
This entry was posted on Wednesd

2007年9月28日 @ 14:41

Changing the filenames in Flex Builder html templa

Changing the filenames in Flex Builder html templates

Suppose you want the main HTML file that wraps your Flash app to be deployed as index.aspx instead of index.html. It’s a little trickier than you might think.

If you look in the html-template directory of your project, you will see that the main file is called index.template.html. This is a special name — Flex Builder recognizes filenameit, and says “Oh I know what that is,” and uses it to create MyApp.html and MyApp-debug.html in the bin folder.

But if you just rename it to index.template.aspx, you’ll have problems. Notice that after doing that, and then cleaning your project, you now have only index.aspx in the bin folder. There are two issues with that: For one thing, the app name isn’t part of the , which cause trouble if you have more than one app in the project; and also, it doesn’t differentiate between the debug and release versions of the file. If you examine it, you’ll see that it contains a reference to MyApp-debug.swf. Where did the release one go?

The answer is that since the file no longer has the special index.template.html name, Flex Builder doesn’t know what to do with it. It does see the “.template” part of the name, and it uses that to decide that it should do macro-substutition within the file; but beyond that, it does nothing more.

2007年9月14日 @ 20:41

AS template for flex(flex AS模版)

////////////////////////////////////////////////////////////////////////////////
//  Copyright (C) 2007 dzq http://www.duzengqiang.com
////////////////////////////////////////////////////////////////////////////////

package
{
   
import mx.events.MoveEvent;

//--------------------------------------
//  Events
//--------------------------------------
/**
 *  Dispatched when the <code>data</code> property changes.
 */
/* [Event(name="dataChange", type="mx.events.FlexEvent")] */

//--------------------------------------
//  Styles
//--------------------------------------
/**
 *  Text color of the label as the user presses it.
 * 
 *  @default 0x000000
 */
 
 
/* [Style(name="textSelectedColor", type="uint", format="Color", inherit="yes")] */
 //--------------------------------------
//  Skins
//--------------------------------------

/**
 *  Name of the class to use as the skin for the background and border
 *  when the button is not selected and the mouse is not over the control.
 * 
 *  @default "mx.skins.halo.ButtonSkin"
 */
/* [Style(name="upSkin", type="Class", inherit="no")] */


//--------------------------------------
//  Other metadata
//--------------------------------------


/* [AccessibilityClass(implementation="mx.accessibility.ButtonAccImpl")]

[DefaultBindingProperty(source="selected", destination="label")]

[DefaultTriggerEvent("click")]

[IconFile("Button.png")] */

/**
 *  The Button control is a commonly used rectangular button.
 *  Button controls look like they can be pressed.
 *  They can have a text label, an icon, or both on their face.
 *  @includeExample examples/ButtonExample.mxml
 */
 
public class template extends *
{   
    //--------------------------------------------------------------------------
    //
    //  Class initialization
    //
    //--------------------------------------------------------------------------
   
    //--------------------------------------------------------------------------
    //
    //  Class resources
    //
    //--------------------------------------------------------------------------
   
    //--------------------------------------------------------------------------
    //
    //  Class constants
    //
    //--------------------------------------------------------------------------

     //--------------------------------------------------------------------------
    //
    //  Class variables
    //
    //--------------------------------------------------------------------------

    //--------------------------------------------------------------------------
    //
    //  Class properties
    //
    //--------------------------------------------------------------------------
   
    //--------------------------------------------------------------------------
    //
    //  Class methods
    //
    //--------------------------------------------------------------------------
   
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor.
     */
    public function template():void{
        super();
    }
    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------
    /**
     *  @private
     */
    
    //--------------------------------------------------------------------------
    //
    //  Overridden properties
    //
    //--------------------------------------------------------------------------
    /**
     *  @private
     */
    
    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------
    /**
     *  @private
     */
    //----------------------------------
    //  data
    //----------------------------------

    /**
     *  @private
     *  Storage for the data property;
     */
   /*  private var _data:Object;

    [Bindable("dataChange")]
    [Inspectable(environment="none")] */

    /**
     *  The <code>data</code> property lets you pass a value
     */
   /*  public function get data():Object
    {
        if (!_data)
            _data = {};

        return _data;
    } */

    /**
     *  @private
     */
   /*  public function set data(value:Object):void
    {
      

        dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
    }
      */
    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------
   
    /**
     *  @private
     */
    
    //--------------------------------------------------------------------------
    //
    //  Methods
    //
    //--------------------------------------------------------------------------
   
    /**
     *  @private
     */
    
    //--------------------------------------------------------------------------
    //
    //  Overridden event handlers: NavBar
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    
    
    //--------------------------------------------------------------------------
    //
    //  Event handlers
    //
    //--------------------------------------------------------------------------
   
    /**
     *  @private
     */
    
}
}

下载

Page:[«]1[»]

Categories

Lately left messages

Comments

Linkage

Misc