MXML, XML, ActionScript

Principles of MXML
MXML and ActionScript are used hand-in-hand to create Rich Internet Applications.

MXML is used with Flex Server and is dynamically compiled into standard binary
SWF files. However, Adobe’s Flex Builder IDE and Flex SDK can also generate SWF
files from MXML for you to use without having the Flex Server.
If you know HTML, then MXML should be fairly easy to understand, since they’re
so similar. MXML is an XML-based markup language; it has a more structured and less
ambiguous syntax than HTML and includes more tags than HTML. For example,
DataGrid, Tree, TabNavigator, Accordion, and Menu are all some of the standard sets
of tags. You can also extend MXML tags and create your own components. But the
most significant difference is that the Flash Player, which enables your users to have
an interactive experience with your web site as opposed to a static HTML-based page,
renders MXML-defined user interfaces. You can also hand-code MXML using an IDE,
such as Eclipse or Intellij.

XML
XML stands for Extensible Markup Language: a general-purpose markup language, just like
HTML, but more restrictive. Standard Generalized Markup Language, or SGML, was the
precursor to XML; hence, XML is a simpler way to code but is a subset of SGML. There
are two levels of correctness for an XML document:
●Well-formed If your document is formed correctly, it conforms to XML’s syntax
rules. For example, if an element has an opening tag with no closing tag and isn’t
self-closing, it’s not well-formed. This then means that a conforming parser isn’t
allowed to process the document.
●Valid A valid document also conforms to some semantic rules. These are either
user-defined or included as an XML schema or DTD. As in the well-formed definition,
if a document contains an undefined tag, then it’s not valid and a validating parser
can’t process it.
Since HTML and XML have proved that they are easy to use and can create user
applications, MXML piggybacked on this success and is really just a derivation of XML.
Principles of ActionScript
Just as MXML is derived from XML, ActionScript is a scripting language based on a
derivation of JavaScript. So, if you already know XML and some JavaScript, half the
battle is already won; you’ll ramp up fast with Flex’s languages. ActionScript was initially
designed for controlling simple 2-D vector animations created in Flash. But ActionScript
was given more functionality as Flash grew, and more current versions allow for the
creation of web-based games and Internet applications with the accompaniment of audio
and video. As you’ll see in the ActionScript timeline, it’s gone through some serious
re-working to make it a robust language.
There were limited interactivity features in the first three versions of Flash, which
meant that ActionScript was limited to attaching a single command to a frame or button.
Then there were also constraints on basic navigation, which only allowed for simplistic
controls, for example:
●Play
●Stop
●Get URL
●Goto

Flex Fundamentals

The Origins of Flex
Originally Flash content was created with the Flash multimedia-authoring program. Flash
supports various capabilities for both vector and raster graphics, the scripting language
ActionScript, and also bidirectional audio and video streaming. Additionally, there are
versions of the Flash Player for mobile phones and other non-PC devices. Strictly speaking,
however, Adobe Flash Professional is an integrated development environment (IDE) and
the Flash Player itself is a virtual machine that an end user exploits to run Flash files. You
can also speak of “running” Flash files as “parsing” them, and we’ll get into that later in
this book. In our technology-driven environment Flash really can refer to the authoring
environment, the player, or the application files.
Unfortunately, Flash was designed with graphic artists in mind and uses a timeline
concept that is foreign to most developers. Flex grew out of the need for a toolkit to create
Flash content that developers understand. Flex provides this by using a workflow and
programming model instead of the timeline.
Flex was initially released as a J2EE application or JSP tag library that compiles a
tagged-based language called MXML and an object-oriented language called ActionScript
directly into Flash applications, which in turn create binary SWF applications. SWF is an
abbreviation for Small Web Format or Shockwave Flash. Each letter is usually pronounced
individually, but most people that work with Flash or Adobe Captivate call it SWF, in
common nomenclature a swiff file. The Flex compiler is still a J2EE application. The
current Flex releases support the creation of static files that are compiled at authoring time
and can be published online, forgoing the need for a server license. There are alternatives
to Flex, such as Ajax, JavaFX, OpenLaszlo, Silverlight, XUL, and the ZK Framework.
For ColdFusion and JSP developers, to use MXML makes sense. On the other hand,
ActionScript should be familiar to Java and other OO developers. But don’t worry if you
are just starting out—that’s what this book is for, to help beginners to Flex get up to speed
as quickly as possible.
Flash and Flex are both applications that give the user live data. This means that web
users don’t have to call your web server again when they decide to change the way the
page loads. If you were using JSP, ASP, or PHP to code your site, the web server would
be consistently queried from the user, whereas if you design your web site in Flash or
Flex, there is no need to ping the web server—anything your web user wants to do is live.

ActionScript
ActionScript is the object-oriented programming (OOP) language that you use in your
Flash files to add interactivity to your applications. But ActionScript is also used by Flex.
ActionScript, like most programming languages, has its own grammar and punctuation
rules, which determine the characters and words used to create meaning and the order in
which they can be written. Take XML as an example: when you’re creating simple tags
such as for bold and for italic, you need to close your bold tag first, then your
italic tag. HTML doesn’t demand this kind of closing tag structure. In PHP, a semicolon
(;) ends your code, and that’s exactly how you end a statement in ActionScript.
ActionScript 1.0 was introduced in its current syntax when Flash 5 was released.
This was the first thoroughly programmable version of Flash. When Flash 6 (MX)
entered the scene, this broadened the programming environment by adding numerous
built-in functions and allowing better programmatic control of movie elements. Flash 7
(MX 2004) introduced ActionScript 2.0, which added strong typing and class-based
programming features. These features included explicit class declarations, inheritance,
interfaces, and Strict Data Typing. Every release of ActionScript shares the same compiled
form within the Flash output as an .swf.
One difference between versions 1.0 and 2.0 of ActionScript is that version 2.0 is
case sensitive. If you first capitalize a variable called Name in your code but later use a
lowercase form for name, the different forms won’t match. ActionScript 3.2 has numerous
changes from ActionScript 2.0. For example, some global functions such as call()
and chr() have been removed in ActionScript 3.2 but were available in 2.0.

MXML
MXML is an XML-based user interface markup language first introduced by Macromedia
in March 2004. Adobe, which acquired Macromedia in December 2005, kept the name,
which some developers believe stands for “Multimedia eXtensible Markup Language.”
Application developers use MXML in combination with ActionScript to develop rich
Internet applications.

Understanding Flex
The biggest reason to use Flex is that it allows web application developers to rapidly and
easily build RIAs. Think of Flex this way: in a multitiered model, Flex applications serve
as the presentation tier. Some examples of a multitiered model are a backend information
source such as a Java process or a database, the application server (web server plus optional
LiveCycle Data Services to talk to the info source tier), and the client (web browser/Flash
plug-in). The client is also called the presentation layer. The application server is sometimes
called the business logic layer.

Follow

Get every new post delivered to your Inbox.