Methods | Properties | Effects | Events | Styles

mx.core
Class Application



class Application
extends mx.containers.Box

Flex defines a default, or Application, container that lets you start adding content to your application without explicitly defining another container. Flex creates this container from the <mx:Application> tag, the first tag in an MXML application file. While you might find it convenient to use the Application container as the only container in your application, in most cases you explicitly define at least one more container before you add any controls to your application.

The Application container is a Box container with the direction set to Vertical by default. It inherits all of the properties of the Box container. This means you can use all of the MXML tag properties and ActionScript methods of the Box container with the <mx:Application> tag.

To revert the style settings of the Application to the plain settings, use the following:

<mx:Application styleName="plain" />

This sets the following:
backgroundcolor="0xFFFFFF;
margintTop="0";
marginBottom="0";
marginLeft="0";
marginRight="0";
horizontalAlign="left";

MXML Syntax

The <mx:Application>tag inherits all the properties of it parent classes, except for the direction property of Box, and the following properties:

 <mx:Application
application="No default."
backgroundImage="Defaults to gray gradient"
backgroundSize="100%"
frameRate="24"
height="100%"
horizontaAlign="center|left|right"
horizontalGap="8"
marginBottom="24"
marginTop="24"
pageTitle"No default."
preloader="No default."
resetHistory="true|false"
scriptRecursionLimit="1000"
scriptTimeLimit="60"
selfContained=""
theme="No default."
usePreloader="true|false"
verticalAlign="top|bottom|middle"
verticalGap="8">
width="100%"
xmlns="No default."
...
child tags
...
/>

The following MXML properties are built into the compiler, not into the Application class itself. For more information, see the chapter `Using the Application Container` in the `Developing Flex Applications` book:

See Also
mx.containers.Box
mx.containers.HBox
mx.controls.Alert
mx.managers.CursorManager
mx.managers.HistoryManager
mx.managers.LayoutManager
mx.managers.SystemManager
mx.managers.DepthManager
mx.managers.PopUpManager
mx.events.EventDispatcher



Constructors
Application ()
This Application constructor never gets called because Flex`s Application object is actually the _root object of the Flash Player; the _root object pre-exists and doesn`t get constructed.


Methods
staticalert(message:String, title:String, flags:Number, clickHandler, defaultButton:Number, icon:String) : Number
Displays a modal dialog box on top of the existing frame.
      constructObject() : Void
This is the first Flex framework method that gets called.
staticgetURL(url, window, variables)
Loads a document from the specified URL into the specified window.
      handleEvent(event:Object) : Void
Triggered by an error or warning event.
      isFontEmbedded(fontFace:String) : Boolean
Returns true if a font face is embedded, and false if it is not.
      onSetFocus(o:Object, n:Object) : Void
Notifies that there is a change in focus.
      popupWindow(className:Object, initObj:Object) : MovieClip
Creates a pop-up TitleWindow container.
      resize()
Triggered by a resize event of the stage.

Methods inherited from class mx.containers.Box
layoutChildren  measure  setRelativeChildHeights  setRelativeChildWidths 

Methods inherited from class mx.containers.Container
createChildren  createComponent  createComponents  draw  getViewMetrics  init 

Methods inherited from class mx.core.View
childLoaded  createChild  createChildren  destroyAllChildren  destroyChild  destroyChildAt  draw  getChildAt  getChildIndex  getViewMetrics  init  layoutChildren  setChildIndex 

Methods inherited from class mx.core.UIComponent
drawFocus  getFocus  getFocusManager  setEnabled  setFocus 

Methods inherited from class mx.core.UIObject
addEventListener  applyProperties  buildDepthTable  commitProperties  constructObject2  createAccessibilityImplementation  createChildAtDepth  createChildren  createClassChildAtDepth  createClassObject  createEmptyObject  destroyObject  dispatchEvent  doLater  draw  drawRect  fillRect  findNextAvailableDepth  getRepeaterItem  getStyle  handleEvent  init  invalidate  invalidateLayout  invalidateProperties  invalidateSize  invalidateStyle  layoutChildren  measure  move  redraw  removeEventListener  setDepthAbove  setDepthBelow  setMask  setSize  setSizeNoLayout  setStyle  swapDepths 


Properties
staticCANCEL:Number
Hex value for the Cancel button that is used later for bitwise comparison.
staticNO:Number
Hex value for the No button that is used later for bitwise comparison.
staticNONMODAL:Number
Hex value for non-modal that is used later for bitwise comparison.
staticOK:Number
Hex value for the OK button that is used later for bitwise comparison.
staticYES:Number
Hex value for the Yes button that is used later for bitwise comparison.
staticapplication:Object
A reference to the top-level application.
      className:String
Name of this class.
      resetHistory:var  [Read-Write]
If true, the application`s history state is reset to its initial state whenever the application is reloaded.
      selfContained:var  [Read-Write]
Indicates whether a SWF is entirely self-referencing or needs to access anything in the loading SWF.
staticversion:String
Version string for this class.

Properties inherited from class mx.containers.Box
direction 

Properties inherited from class mx.containers.Container
autoLayout  childDescriptors  className  clipContent  creationPolicy  defaultButton  hLineScrollSize  hPageScrollSize  hPosition  hScrollPolicy  icon  label  maxHPosition  maxVPosition  numRepeaters  vLineScrollSize  vPageScrollSize  vPosition  vScrollPolicy  version 

Properties inherited from class mx.core.View
baselinePosition  className  numChildren  tabIndex  version 

Properties inherited from class mx.core.UIComponent
enabled  errorString  tabEnabled  tabIndex  version 

Properties inherited from class mx.core.UIObject
alpha  baselinePosition  className  depth  documentDescriptor  height  heightFlex  id  instanceIndices  isDocument  kStretch  layoutHeight  layoutWidth  maxHeight  maxWidth  minHeight  minWidth  mouseX  mouseY  nestLevel  oldHeight  oldWidth  oldX  oldY  parent  parentApplication  parentDocument  preferredHeight  preferredWidth  repeaterIndices  scaleX  scaleY  styleName  tabEnabled  toolTip  version  visible  width  widthFlex  x  y 


Effects

Effects inherited from class mx.core.UIComponent
focusInEffect  focusOutEffect 

Effects inherited from class mx.core.UIObject
creationCompleteEffect  hideEffect  mouseDownEffect  mouseOutEffect  mouseOverEffect  mouseUpEffect  moveEffect  resizeEffect  showEffect 


Events

Events inherited from class: mx.containers.Container
childrenCreated  scroll 

Events inherited from class: mx.core.View
childCreated  childDestroyed  childIndexChanged 

Events inherited from class: mx.core.UIComponent
focusIn  focusOut  invalid  keyDown  keyUp  valid  valueCommitted 

Events inherited from class: mx.core.UIObject
creationComplete  dragComplete  dragDrop  dragEnter  dragExit  dragOver  draw  effectEnd  effectStart  hide  initialize  mouseChangeSomewhere  mouseDown  mouseDownSomewhere  mouseMove  mouseMoveSomewhere  mouseOut  mouseOver  mouseUp  mouseUpSomewhere  move  resize  show  unload 


Styles

Styles inherited from class mx.containers.Box
horizontalAlign  horizontalGap  marginBottom  marginTop  verticalAlign  verticalGap 

Styles inherited from class mx.core.UIComponent
backgroundAlpha  backgroundColor  backgroundDisabledColor  backgroundImage  backgroundSize  barColor  borderCapColor  borderColor  borderStyle  buttonColor  disabledColor  errorColor  highlightColor  lineHeight  modalTransparency  scrollTrackColor  shadowCapColor  shadowColor  symbolBackgroundColor  symbolBackgroundDisabledColor  symbolBackgroundPressedColor  symbolColor  symbolDisabledColor  themeColor 

Styles inherited from class mx.core.UIObject
color  fontFamily  fontSize  fontStyle  fontWeight  horizontalGap  marginLeft  marginRight  textAlign  textDecoration  textIndent  verticalGap 


Constructor Detail

Application

Application()

This Application constructor never gets called because Flex`s Application object is actually the _root object of the Flash Player; the _root object pre-exists and doesn`t get constructed.


Method Detail

alert

static alert(message:String, title:String, flags:Number, clickHandler, defaultButton:Number, icon:String) : Number

Displays a modal dialog box on top of the existing frame. The box is removed when the user clicks on any button.

Optional title text can appear in the title bar of the alert, along with a variety of choices of which buttons to display. The parameters map directly to those of the Alert class.

Parameters
    message - Text content to display.
    title - Text to display in title bar (optional).
    flags - Defines buttons to display. See Alert.show(). (optional)
    clickHandler - Called when a button is clicked See Alert.show(). (optional)
    defaultButton - Defines the default button that is selected when the user presses the Enter key. (optional)
    icon - Icon displayed to the left of message text. (optional)

Returns
    Zero (0) if the Alert was displayed, non-zero otherwise.


constructObject

constructObject() : Void

This is the first Flex framework method that gets called. The autogenerated Frame 1 action for a Flex application changes _root`s __proto__ to MyApplication, and then calls constructObject() on _root. The autogenerated MyApplication class does not override Application`s constructObject(), so this method is invoked.


getURL

static getURL(url, window, variables)

Loads a document from the specified URL into the specified window. If you reference this method from a file that does not contain the <mx:Application> tag, you must either import mx.core.Application, or use the fully-qualified method name of mx.core.Application.getURL().

Parameters
    url - A string specifying the URL.
    window - The target window in which to open the URL.
    variables - Do not set.


handleEvent

handleEvent(event:Object) : Void

Triggered by an error or warning event. By default, this method displays an Alert dialog that contains the text message.

Parameters
    event - Event.


isFontEmbedded

isFontEmbedded(fontFace:String) : Boolean

Returns true if a font face is embedded, and false if it is not.

Parameters
    fontFace - Font face to check.


onSetFocus

onSetFocus(o:Object, n:Object) : Void

Notifies that there is a change in focus.

Parameters
    o - Object that had focus.
    n - Object that currently has focus.


popupWindow

popupWindow(className:Object, initObj:Object) : MovieClip

Creates a pop-up TitleWindow container.

Parameters
    className - A reference to a class. The class name should be expressed without quotation marks, as in popupWindow(mx.containers.TitleWindow).
    initObj - Object that contains initialization properties. This argument is optional.


resize

resize()

Triggered by a resize event of the stage. Sets the new width and height. After the SystemManager performs its function, it is only necessary to notify the children of the change.


Property Detail

application

static application:Object  

A reference to the top-level application. In general, there can be a hierarchy of Application objects, because an Application can have a Loader which dynamically loads another Application. The `parentApplication` property of a UIObject can be used to access the sub-Application in which that UIObject lives, and to walk up the hierarchy to the top-level Application.


CANCEL

static CANCEL:Number  

Hex value for the Cancel button that is used later for bitwise comparison.


className

className:String  

Name of this class.


NO

static NO:Number  

Hex value for the No button that is used later for bitwise comparison.


NONMODAL

static NONMODAL:Number  

Hex value for non-modal that is used later for bitwise comparison.


OK

static OK:Number  

Hex value for the OK button that is used later for bitwise comparison.


resetHistory

resetHistory:var  [Read-Write]

If true, the application`s history state is reset to its initial state whenever the application is reloaded. Applications are reloaded when any of the following occurs:
The default value is true.


selfContained

selfContained:var  [Read-Write]

Indicates whether a SWF is entirely self-referencing or needs to access anything in the loading SWF. This is used when one SWF loads another SWF.


version

static version:String  

Version string for this class.


YES

static YES:Number  

Hex value for the Yes button that is used later for bitwise comparison.