In this section, we use arrays to create a dynamic code-built menu that you can adjust for any Flash movie. You create a Main Timeline with six sections for a photographer’s site, and a menu that navigates to those four sections. While that sounds simple enough, we create the menu entirely from ActionScript code.
code (note that the ¬ indicates a continuation of the same line of code; do not insert this character into your actual code):sectionNames = new Array(“about”, “interiors”, ¬ “exteriors”, “landscapes”,”portraits”, “editorial”);
This line of ActionScript will create an array object named sectionNames. We can now refer to each section of our timeline using array syntax, such as sectionNames, sectionNames, and so on. We use this array to build the actual button text in our menu.
This code creates a new variable named sectionCount. The length property of an array will return the current number of elements inside of the array. Therefore, because we put six elements into the array (in Step 6), sectionCount will be equal to 6. You may be wondering why we just didn’t manually insert the value 6 here. The point to using an array is that we can change the elements of the array at any point, and the rest of our code will update automatically to reflect the changes. In this way, we are building a dynamic menu system.
The Main Timeline has frame labels and artwork for each section of the presentation.
This layer will hold a template Movie Clip instance for the menu item(s). Again, create a new Movie Clip symbol by pressing Ctrl+F8 (Command+F8). Name this symbol menuItem, and keep the default Movie Clip behavior.
This will be the actual button that appears in our menu. Make sure that the Button is wide enough to accommodate the names of our sections. We stretched our button, shown in Figure below, to 175 percent. Also, center your Button instance on the Stage, using the Align Panel.
The menuItem instance will be used to create each button in the dynamic menu. Using Action Script, the label Name text field will be filled with the appropriate section name.
This code will use the value of the labelName text field as the frame label for the gotoAndStop() action. Notice that we will control the Main Timeline’s playhead by indicating _root. Shortly, we will assign each instance of menuItem a unique labelName value.
We will duplicate the menuItemBase instance in ActionScript, to build each button in the menu symbol.
This line of code establishes a variable named menuItemSpacing. This value will designate the space (in pixels) to space each menuItem instance apart.
This code inserts a for loop that will duplicate the menuItemBase instance (inside of the menu instance) for each element in the sectionNames array. It will also set the value of labelName in each duplicated menuItem instance to the name of the appropriate section name. Notice that we specify i-1 for the index number of the sectionNames array because the position index of every array starts at 0 and our menuItem numbering starts at 1. After an instance is duplicated for the section name, we then reposition the menuItem instance below the previous one. We only need to perform this operation for instances greater than 1 because the starting instance does not need to be moved down. Notice also that we use the menuItemSpacing variable add a buffer space between the menu items.
The ActionScript code in the menu actions layer duplicates the menuItemBase instance in the menu instance. Each duplicated instance has a unique labelName value, which is used in the gotoAndStop() action by each Button instance.
You can enhance this dynamic menu by adding animation to the menuItem symbol timeline. You can also restructure the ActionScript to work with separate Movie Clips for each sectionName, instead of frame labels. If used properly, you may never need to script a menu again! Simply change the Button instance artwork and text styles for unique menu interfaces.
Flash Related Interview Questions
|Adv Java Interview Questions||J2EE Interview Questions|
|Adobe Flex 3 Interview Questions||Dreamweaver Interview Questions|
|3D Animation Interview Questions||Adobe Flash CS6 Interview Questions|
|Dreamweaver CS3 Interview Questions||Adobe Flex Interview Questions|
|Adobe Flex Actionscript Interview Questions||Gif Animation Interview Questions|
|Adobe Fireworks Interview Questions|
Understanding The Flash Framework
Exploring The Interface: Panels, Settings, And More
Using Tools For Navigation And Viewing
Working With Selections And The Pen Tool
Working With The Drawing And Painting Tools
Working With Text
Exploring The Timeline
Checking Out The Library: Symbols And Instances
Drawing In Flash
Animating In Flash
Using Bitmaps And Other Media With Flash
Designing Interfaces And Interface Elements
Understanding Sound For Flash
Importing And Editing Sounds In Flash
Optimizing Flash Sound For Export
Understanding Actions And Event Handlers
Navigating Flash Timelines
Controlling Movie Clips
Sharing And Loading Assets
Planning Code Structures
Creating Subroutines And Manipulating Data
Understanding Movie Clips As Complex Objects
Sending Data In And Out Of Flash
Understanding Html And Text Field Functions In Flash
What Is Generator?
Revving Up Generator
Working With Third-party, Server-side Applications
Working With Raster Graphics
Working With Vector Graphics
Working With Audio Applications
Working With 3d Graphics
Working With Quicktime
Working With Realplayer
Creating Full-motion Video With Flash
Creating Cartoon Animation With Flash
Planning Flash Production With Flowcharting Software
Working With Authoring Applications
Publishing Flash Movies
Integrating Flash Content With Html
Using Players, Projectors, And Screensaver Utilities
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.