Adding Media

As mentioned before, you can add media to an application by either loading it or embedding it. In this section, we will discuss the different syntax for loading and embedding media. This will serve as a good foundation for understanding the methods you have available to you when adding media to a Flex application. In the Flex framework, watch for component properties that accept a variable of type Class. These properties usually indicate the ability to accept a media type as a value.

Note

If you have experience with developing Flash applications, you may be accustomed to creating classes for symbols such as images for when you want to access them in ActionScript. In Flex, this is no longer required as the compiler generates such classes for you automatically.

Loading Media

The easiest and most common way to load media at runtime is to use one of the MXML components specifically designed for that job. A variety of components are available for different types of media. You can use an Image component to load images, an SWFLoader component to load .swf files, or a VideoDisplay component to load video content. The Image component is the most commonly used of these components and the one we will focus on in this section.

Note

Internally, Flex makes use of Flash Player’s Loader class. You typically will not make use of the Loader class directly as the Flex framework abstracts away the details, but it is good to know that it exists and that if you ever need to implement the loading ...

Get Programming Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.