FlashComponents
  Flash Templates
  Flash Gallery
  Flash Slideshow
  Flash Menu
  Flash Design
  Flash Video
  FLV Player

 

 

 

 

 
XML-Driven Drop-Down Menu
         by senocular

XML Format
The format of the XML defining our menu will have to accommodate the specifications indicated. This includes defining a name, an action and a differentiation between a normal clickable menu item and one which opens up a submenu. Certainly there are many ways to fit these in an XML document, and that all depends on preference. For today, we'll use the following.

<?xml version="1.0"?>
<menu name="">
<item name="" action="" variables=""/>
<menu name="name"/>
<item name="" action="" variables=""/>
</menu>
</menu>

Here we have a hierarchy set up of menu and item XML nodes. Each menu node represents a collection of more item or menu nodes - or a submenu of the current menu. Item nodes are basic menu options. Both menu and item nodes contain a name attribute specifying that node's name, or display value. Each item node then also gets an action and a variables attribute which will determine what happens when that item is pressed. An action could also be associated with a menu node if desired, but since their purpose is often just to open up a submenu and nothing more.

Example Menu XML
This, or a version of this, will be used in the final Flash menu created.
 

This XML file represents a menu of links. The very first XML node is a menu node representing the main menu. This was given the name links, but since you will never see this name, it is mostly irrelevant though it can serve to help you know what kind of menu this is when editing it. The first two options under this main menu, macromedia and kirupa, are submenus which lead to a collection of other links followed by one basic link item. The kirupa submenu, contains yet another submenu called tutorials. It has its own collection of links. You might be able to see this a little better given the XML excluding the attributes. Then you have this.

<menu>
<menu>
<item/>
<item/>
<item/>
</menu>
<menu>
<item/>
<item/>
<menu>
<item/>
<item/>
<item/>
</menu>
</menu>
<item/>
</menu>

The attributes, however, are needed to help define the menu. Within each node , both types, you'll find a name attribute. If an item node, an action and variables attribute is included too. Since this particular menu is a menu of links, the action given was "gotoURL" and the variables included a URL string. That gives you something like the following.

<item name="google" action="gotoURL" variables="http://www.google.com"/>

When this particular item, google, is clicked, this menu item will open up google.com in a browser window. This action, as well as any other for that matter, needs to be interpreted in Flash, though. Just having "gotoURL" in an XML document means nothing by itself. Its up to you to extract that and make something happen when its read into Flash - actually have that gotoURL mean go to a URL. Lets begin working on that next.

 

 

 


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
Streamsolutions Content Delivery Networks Buy and sell FLAs.
cdn
      content delivery network (cdn)
Flipping Book - page flip flash component. Learn how to advertise on kirupa.com