12. Decide which elements of your Flash (Web site traffic) movie

12. Decide which elements of your Flash movie will change when a menu item in the combo box is selected. Add those elements to the Flash movie if you haven t already done so. If, for example, you decide that the contents of a dynamic text box will change when a menu item in the combo box is selected, create a dynamic text box on the Stage and give it an instance name, such as myInfo3. (See Chapter 5 to discover how to create dynamic text.) 13. Choose Window.Actions to open the Actions panel if it isn t open already, and in the Actions panel click the Script Assist button to deselect it, if it s selected. 14. Select Frame 1 in the Timeline and enter the following code in the Script pane of the Actions panel: myEvent3 = new Object(); myForm3 = new Object(); myForm3.change = function(myEvent3){ myInfo3.text = myComboBox.selectedItem.label; } myComboBox.addEventListener( change ,myForm3); You can replace myForm3, myEvent3, myInfo3, and myComboBox with any names that you like. myInfo3 in this example is the name of the dynamic text field that we mention in Step 12, and myComboBox is the instance name of your combo box. When you play your Flash movie, note the sleek, subtle animation when you click the combo box, which is impossible with a plain old HTML Web page. Lines 1 and 2 of the preceding code create new little bundles of methods and properties named myEvent3 and myForm3. Line 6 adds an event listener to myForm3 so that when you select one of the menu items in myComboBox, the code in lines 3, 4, and 5 sets the text of the dynamic text field to whatever is the label of the combo box menu item that the viewer selects. The third, fourth, and fifth lines of code show an example of how to change the contents of the dynamic text box that we describe in Step 12, but you can replace this line with other ActionScript code to do something else. For example, here you might instead put some ActionScript code that sets the Flash playhead to move to different sections of the movie depending on which menu item in the combo box is selected. If things aren t working when you test your combo box, there may be typos or other errors in the ActionScript code that you typed in. Flash often reports these errors in the Output panel when you choose Control.Test Movie. The error messages in the Output window may seem obscure, but they can give you an idea of where your problem may be. 264 Part V: The Movie and the Web
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Leave a Reply