Chapter 12 Working with Components © 2011 Delmar, Cengage Learning Chapter 12 Lessons 1. Use Components in a Flash Movie 2. Work with Components and ActionScript © 2011 Delmar Cengage Learning Work with Components • Introduction – There are three categories of components: 1. User Interface (UI)—Components (such as buttons and menus) that are used to create the visual interface for a Flash application 2. Video—Components used to insert an flv video file into a Flash document and allow the user to control the playback video 3. Flex—Contains the FlexComponentBase class that is used to develop and deploy cross-platform applications © 2011 Delmar Cengage Learning Working with Components • Introduction – You can use components for creating check boxes, drop-down menus, and forms with boxes for entering user data – You can add functionality to a movie by dragging and dropping components from the Components panel to the Stage – You are not required to enter ActionScript code when using components © 2011 Delmar Cengage Learning Working with Components • Introduction – However, you can use ActionScript to enhance the functionality of a component – In addition to the components provided in Flash, you can obtain other components from third-party companies and individuals © 2011 Delmar Cengage Learning Working with Components Tools You’ll Use © 2011 Delmar Cengage Learning Use Components in a Flash Movie Each component name and icon provides a clue to its type, such as Button, CheckBox, and ScrollPane. Components panel showing the User Interface Components © 2011 Delmar Cengage Learning Use Components in a Flash Movie • Many of the User Interface Components are used as part of forms that can gather data from a user. • The UILoader Component can load external .jpg graphic files and .swf movie files. • You can load these files from a folder, using a relative or an absolute path. © 2011 Delmar Cengage Learning Use Components in a Flash Movie • When you load the files from a folder, it will reduce the size of the movie and allow you to easily update website content by simply changing the .jpg or .swf files on the external site. • You can load files using ActionScript or by using the UILoader. © 2011 Delmar Cengage Learning Use Components in a Flash Movie • Depending on the type of component used, you will need to specify one or more of the following parameters: – source—This parameter is used to specify the location for the content that is to be displayed using the component – scaleContent—This parameter can be turned on and off. If it is on the content will automatically resize to the size of the component. If it is off, the UILoader will be scaled to the smaller size associated with the object © 2011 Delmar Cengage Learning Use Components in a Flash Movie • Parameters Continued… – autoLoad—This parameter can be turned on and off. If it is turned on, the Component will automatically display the specified contents. If it is turned off, the contents will not be displayed until some other action you specify, such as a button click, occurs – label—This parameter allows you to type a text label © 2011 Delmar Cengage Learning Use Components in a Flash Movie The completed Component Parameters © 2011 Delmar Cengage Learning Use Components in a Flash Movie • To use a Component: 1. Select the frame and layer where the component will be placed 2. Drag the component from the Components panel to the desired location on the Stage 3. Use the Properties panel to set the component parameters © 2011 Delmar Cengage Learning Work with Components and ActionScript • You can use ActionScript to enhance the user experience. – Example: Add feedback that lets the user know the progress of an image that is being loaded © 2011 Delmar Cengage Learning Work with Components and ActionScript A message that displays as an image is loaded © 2011 Delmar Cengage Learning Work with Components and ActionScript • The process for using ActionScript for loading an image into a component – Checking the loading progress – Displaying a message about the loading progress – Checking for when the loading is complete – Playing an animation after the image loads © 2011 Delmar Cengage Learning Work with Components and ActionScript When the image has loaded the message is removed and an animation plays. © 2011 Delmar Cengage Learning Work with Components and ActionScript • You can add additional code to set parameters for the UILoader using the ActionScript code rather than the Properties panel. • This works well for images that have a large file size. © 2011 Delmar Cengage Learning