Skip To Content

MXML and ActionScript in Flex applications

In this topic

Version 3.7

Flex applications are developed using the MXML and ActionScript languages with the ActionScript class library, which contains components, manager classes, data service classes, and classes for all other features.

Learn more about developing with Flex

MXML can be compared to HTML (tags that lay out the page), and ActionScript can be compared to JavaScript (the coding). In theory, you could write everything as ActionScript code (add a button here, put the map at the bottom of the page, and so on), but this is neither practical nor maintainable.

ActionScript 3 syntax is similar to other languages such as C, C#, C++, and Java. ActionScript is an object-oriented procedural programming language and includes Java object-oriented features, such as extending classes and implementing interfaces.

Combining MXML and ActionScript

The following are the different ways you can combine MXML and ActionScript:

  • Use ActionScript in MXML event handlers:
    <esri:map load="'map is loaded')">
  • Use ActionScript <mx:Script> or <mx:initialize> blocks in MXML files:
            import mx.controls.Alert;
            private function onMapLoad():void
      'Hola Mundo');
  • Include external ActionScript files:
    include "";
  • Import ActionScript classes.


Multiple steps take place behind the scenes when Flex compiles your application. The application is parsed by MXMLC, translated into an ActionScript file, and compiled into a SWF file.

To better understand how Flex converts MXML tags into code, you can view the interim ActionScript files. These are deleted unless you specify the "...keep-generated-actionscript" option when compiling your application.