Flylib.com

Books Software

 
 
 

Creating Flash Applications with Flex

Creating Flash Applications with Flex

Macromedia Flex is an alternative means of creating Flash applications. It is a presentation server that is installed on a web server. At the time of writing, Flex was only available for Suns Java 2 Enterprise Edition (J2EE) application servers.

Flex includes a library of components and uses Macromedias Maximum Experience Markup Language (MXML), an XML-based language to describe the interface for an application with ActionScript. MXML lays out the visual components and defines aspects like data sources and data bindings. You can also extend MXML with custom components .

You write the MXML in XML files using a text or XML editor. You can also use Macromedias Flex Builder. Each MXML file must end with the file extension .mxml . Learning about XML will help you to use Flex to create applications.

I havent covered Flex in this book as it could be an entire book in its own right. You can find out more about it at www.macromedia.com/software/flex/.

Summary

In this chapter, I covered a brief introduction to Flash and XML. I looked at some of the reasons why developers might use Flash with XML in their applications. I also showed you some sample applications that use Flash and XML together.

In the next chapter, Ill introduce you to XML and explain how to create XML documents. Well look at the meaning of the word well formed and examine the differences between XML, HTML, and XHTML. Chapter 3 will go into more detail about XML documents and well look at Document Type Definitions (DTDs), XML schemas, and Extensible Stylesheet Language Transformations (XSLT). If you have experience in working with XML documents, you might want to skip ahead to Chapter 4, where well start to build Flash XML applications.

Chapter 2: Introduction to XML

Overview

If you work in the web design or development area, youve probably heard of XML. You may have come across it when you were learning how to write web pages or when you started exploring web services. Many software programs share information using XML documents, and Office 2003 for PCs lets you work with XML documents. So what is all the hype about and why should you know about XML?

XML is rapidly becoming the standard for exchanging information between applications, people, and over the Internet. Both humans and computers can read XML documents, and as a format, XML is flexible enough to be adapted for many different purposes.

This chapter introduces you to XML. It explains some of the basic concepts, including the rules governing the structure of XML documents. Youll also learn about some of the uses for XML and the reasons why should you start to use XML in your projects. I show some examples of XML documents, and by the end of the chapter, youll have a solid understanding of XML and related concepts.

Ill expand on the concepts covered here in Chapter 3, where well look at using an XML editor and creating XML content with Office 2003. Ill also look at some related topicsdefining XML document rules with schemas and changing the appearance of XML documents with transformations.

What is XML?

Lets start by answering the most basic question: What is XML?

The World Wide Web Consortium (W3C) provides the following definition for XML in their glossary at www.w3.org/TR/DOM-Level-2-Core/glossary.html:

Extensible Markup Language (XML) is an extremely simple dialect of SGML. The goal is to enable generic SGML to be served , received, and processed on the Web in the way that is now possible with HTML. XML has been designed for ease of implementation and for interoperability with both SGML and HTML.

As you can see from this definition, its very difficult to explain XML in a single sentence or paragraph. To start with, XML stands for Extensible Markup Language . Extensible means that you can use XML to create your own languages. The term markup means that the languages you create use tags to surround or mark up text.

XML is not a markup language like HTML. It is a meta-language that you can use to create other markup languages. The languages that you create work with structured data, and you use XML to invent tags that describe your data and the data structures. You can use different tags each time you create an XML document, or you can use the same tags for different documents.

Groups have created their own languages based on XML. This allows them to share information specific to their industry or area of expertise using a common set of markup tags and structures.

One example, Chemical Markup Language (CML), allows scientists to share molecular information in a standardized way. There are specific rules for structuring CML documents and referring to molecular information. MathML is another example of a standard language using XML. XML documents can use MathML to describe mathematical operations.

Extensible HTML (XHTML) is an example that is probably more familiar to you. XHTML was created when HTML was rewritten according to XML rules.

Think about the tags you use in XHTML <p></p> , <h1></h1> . These tags mark up information on a web page, and you use them in a specific way, according to some predefined rules. For instance, one rule says that you cant include <p></p> tags in the <head> section of a web page.

Being familiar with these rules means that you can open any web page written in XHTML and understand the structure. It also means that any software package that knows the XHTML rules can display a web page.

By itself, XML doesnt do anything other than store information. Its not a programming language in its own right. XML documents need humans or software packages to process the information that they contain.

XML documents work best with structured information such as names and addresses, product catalogs, and lists of documentsanything with a standardized format. You can store hierarchical information within XML documents, a bit like storing information in a database. Instead of breaking the information into tables and fields, you use elements and tags to describe the data.

This concept is a little easier to explore with an example. Most of us have a phone book that we use to store contact information for our friends and colleagues. You probably have the information in a software package like Microsoft Outlook or Outlook Express.

Your phone book contains many different names but you store the same information about each contact their name , phone number, and address. The way the information is stored depends on the software package youve chosen . If the manufacturer changed the package or discontinued it, youd have to find a new way to store information about your contacts.

Transferring the information to a new software program is likely to be difficult. Youd have to export it from the first package, rearrange the contents to suit the second package, and then import the data. Most software applications dont share a standard format for contact data, although some can talk to each other. You have to rely on the standards created by each company.

As an alternative, you can use XML to store the information. You create your own tag names to describe the data; tags like <contact> , <phone> , and <address> provide clear descriptions for your information. Anyone else who looks at the file will be able to understand what information you are storing.

Because your phone book XML document is in a standard format, you can display the details on a web page. Web browsers contain an XML parser to process the XML content. You can also print out your contacts or even build a Flash movie to display and manage your contacts.

Your friends could agree on which tags to use and share their address books with each other. You can all save your contacts in the same place and use tags to determine who has contributed each entry. When you use a standardized structure for storage, the ways that you can work with the information are endless.