Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Digital Audio, Video > Adobe Flash

From Flash to Flex: Creating ActionScript Components for Flex

  • Print
  • + Share This
Do you want to develop applications more quickly, write cleaner code, and use external sources as the data that drives your applications? Kris Hadlock explains how to create an ActionScript component for Flex by using XML as a data source to offer reusability in your Flex applications.
Like this article? We recommend

Like this article? We recommend

The Flash to Flex series has covered the basic creation of a Flex project and making a move to ActionScript 3 (AS3). In this article we will take a deeper look at class creation in Flex and learn how to develop a reusable component for displaying and rotating headlines in any Flex application.

The source code for the example in this article can be downloaded here.

Defining an XML Structure

When creating an XML-driven component, the first logical step is to define the XML structure that it will request so we can understand how to parse it.

In this example, we will create a component that rotates between multiple headlines and displays them as hyperlinks that we define the URLs for. Listing 1 shows an example of the XML structure that we will use in the component.

Listing 1: XML structure for headlines

<?xml version="1.0" encoding="ISO-8859-1" ?>
<headlines>
   <headline action="http://www.studiosedition.com"><![CDATA[Visit Studio Sedition]]></headline>
   <headline action="http://www.studiosedition.com/articles"><![CDATA[View all of my articles]]></headline>
</headlines>

The structure has the capability to add multiple headlines as CDATA to enable HTML rendering, and each headline has an action attribute that points to a URL. Now that we have our XML structure, let’s start creating our component.

  • + Share This
  • 🔖 Save To Your Account