Advanced Flash XML Menu
In this tutorial I will teach you how to create an advanced XML menu. We will first set up everything ready in Flash, then create the XML file and finally add some ActionScript 3 for the functionality. Hope you enjoy the tut!
Setting up the environment
1. Create a new document of size 400×350.
2. First, let’s create a menu item. Draw a rectangle of size 40×40. Convert it into a movie clip named “menuItem”. Set the registration point to the bottom left corner. I used a 4 pixels wide white stroke and for the fill #ff8800.
3. Inside the menu item movie clip, create a new layer and add a dynamic text field in the center of the menu item. Set the text-align to center. Type some number in the text field, e.g. “1″. I used a font size of 16 for my textfield.

4. Embed the numberals in the text field.

5. Give the text field an instance name of “menuText“.
6. Linkage the menu item movie clip to a class named “MenuItem“. If you don’t know how to linkage movie clips, please see step 4 from the External Classes tutorial.
7. Delete the menu item from the stage. We will create all the items dynamically with XML and ActionScript 3.
Creating the XML
8. Create a new text file and type the following.
<?xml version="1.0" encoding="utf-8"?>
<menus>
<menu id="1">
<item>1.1</item>
<item>1.2</item>
</menu>
<menu id="2">
<item>2.1</item>
<item>2.2</item>
<item>2.3</item>
<item>2.4</item>
</menu>
<menu id="3">
<item>3.1</item>
<item>3.2</item>
<item>3.3</item>
<item>3.4</item>
</menu>
<menu id="4">
<item>4.1</item>
<item>4.2</item>
<item>4.3</item>
</menu>
</menus>
9. Save the file as “flash_menu.xml“.
Moving to ActionScript 3
10. Type the following in the first frame of your Flash movie. Feel free to change the XML filepath to match your settings!
//Import TweenMax for animation
import gs.*;
import gs.easing.*;
import gs.plugins.*;
TweenPlugin.activate([GlowFilterPlugin]);
//Save menu item's height to a constant variable
const ITEM_HEIGHT:Number = 50;
//Save the path to the XML file
var xmlPath:String = "http://flashmymind.com/xml/flash_menu.xml";
//The XML data will be inserted into this variable
var xml:XML;
//Set the floor (= y coordinate) for the menu items
var floor:Number = stage.stageHeight - 20;
//We want to know which menu array is currently selected
var selectedMenu:Array;
//We want to keep track how many menus have been created
var menuCounter:uint = 0;
// Load the XML file
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
//This function is called when the XML file is loaded
function xmlLoaded(e:Event):void {
//Make sure we're not working with a null loader
if ((e.target as URLLoader) != null ) {
//Insert the loaded data to our XML variable
xml = new XML(loader.data);
//Ignore white space
xml.ignoreWhitespace = true;
//Call the function that creates the whole menu
createMenus();
}
}
//This function creates the menus
function createMenus():void {
//Loop through the menus found in the XML file
for each (var menu:XML in xml.menu) {
//We create a menu for each menu found in the xml.
//We pass the "menu" xml data as a parameter to the function.
var menuItems:Array = createMenu(menu);
//Position the menu items that are in the menuItems
for (var i= 0; i< menuItems.length; i++) {
//Set the x and y coordinates
menuItems[i].y = floor;
menuItems[i].x = -30 + menuCounter * 80;
//Add the item to stage
addChild(menuItems[i]);
}
}
}
//This function creates a single menu (= one vertical menu).
//It returns all the menu items which belong to the created menu.
function createMenu(menu:XML):Array {
//Create an array which contains all the items in this menu
var menuItems:Array = new Array();
//Loop through the items found in the menu
for each (var item:XML in menu.item) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Set the item text
menuItem.menuText.text = item.toString();
//Set the menuItem to have no mouseChildres
menuItem.mouseChildren = false;
//Add the item to the menuArray
menuItems.push(menuItem);
}
//We also need to create the main MenuItem for the menu
var mainItem:MenuItem = new MenuItem();
//Set the mainItem to have no mouseChildren
mainItem.mouseChildren = false;
//Add the main item to menuArray
menuItems.push(mainItem);
//Save the array to which this mainItem belongs to.
//We need this in the animation later on.
mainItem.belongsToMenu = menuItems;
//Set the "id" attribute to be the main item's text
mainItem.menuText.text = menu. @ id;
//Add CLICK listener for the mainItem
mainItem.addEventListener(MouseEvent.CLICK, mainItemClicked);
//Update the menuCounter since we just created a new menu
menuCounter++;
//Return the menuArray that contains all the items in this menu
return menuItems;
}
//This function is called when a menu's mainItem is clicked
function mainItemClicked(e:Event):void {
//Animate the previous menu down if there is one
if (selectedMenu) {
for (var i =0; i< selectedMenu.length-1; i++) {
TweenMax.to(selectedMenu[i], 0.5 , {y:floor, glowFilter:{color:0x324df, alpha:0, blurX:0, blurY:0}});
}
}
//Get the menu where the mainItem is located
var clickedMenu:Array = e.target.belongsToMenu;
//Set the clickedMenu to be our selectedMenu
selectedMenu = clickedMenu;
//Loop through the items except for the last one which is the mainItem.
//We don't animate the mainItem
for (var j =0; j< selectedMenu.length-1; j++) {
//Save the item to a local variable
var item = selectedMenu[j];
//Calcute the target y coordinate for the item.
var targetY:Number = floor - ITEM_HEIGHT*1.2*(1 + j);
//Tween an item up.
TweenMax.to(item, 0.5 , {y:targetY, glowFilter:{color:0xffffff, alpha:1, blurX:20, blurY:20}});
}
}
11. You are done
How to Add Interactivity to a Button Inside Adobe Flash CS4
short video tutorial on how to make a button "work" inside Adobe Flash CS4. It's a little different with the new ActionScript 3.0, so I decided I'd make a video on it. I'd also like to tell you that in ActionScript 3.0, all the actions are in the timeline, meaning you cannot give objects their own set of actions anymore.
Actions used in the video.
Give the object an instance name first, as shown.
Then, add an event listener like:
instanceNameHere.addEventListener(MouseE vent.CLICK,mouseClick);
Then, you have to define the function, mouseClick.
function mouseClick(event:MouseEvent):void
{
insert what you want to happen here
}
Possible actions:
You can go to another frame and play the video: gotoAndPlay(framenumber);
You can go to another frame and stop the video:
gotoAndStop(framenumber)
You can play the video:
play();
You can stop the video:
stop();
Create “skip intro” button
Skip Intro.
Add "Skip Intro" button to larger Flash animations so inpatient or dial-up users can go straight to your home page.
Use "Skip Intro" button on preloader frame.
- Launch Flash Designer and choose "Blank Animation". Choose "Frame" > "Frame Size" to set movie dimensions.
- Choose "Movie" > "Edit Preloader"
- Choose "Button Tool" and draw a button in the right bottom corner.
- Double-click the button to rename it, enter" "Skip Button" and click OK.
- Choose "Item" > "Action" > "OnClick", check "Get URL" and enter the URL of your home page (the page after the intro). The URL must be absolute (begin with http://)
- Choose "Movie" > "Go to Main Movie" to quit preloader.
Pages
Advertise Here
Categories
- ActionScript
- design
- Flash animation
- flash conf
- Flash cs3
- Flash CS4
- flash dhtml
- flash scripts
- Flash Sound
- Flash Video Tutorials
- Google Maps
- How To
- JavaScript
- PSP
Archives
Tags
Recent Posts
- How to Create circular path animation
- How to Move objects with 3D Translation tool
- Flash CS4 3D graphics example
- Create a Music Video Composition in Flash
- Flash AS3 simplebutton
- How to Use a locked gradient and bitmap fill
- How to Modify painted area
- How to Delete or Duplicate colors in the Flash palette
- How to use Flash stroke and Tools panel
- AS3 Custom Cursor
- How to create Flash Bubble effect
- How to Create and edit a gradient fill
- How To Create or edit a solid color
- Flash CS4 Color palettes
- Flash CS4 Color panel
Random Posts
- Create a Flash Preloader
- How to Control flash timeline playback
- Install Flash Player 10 on 64bit OpenSuse
- Custom Context Menu Flash CS3
- Flash Media Server 2: Some basic concepts
- Cylindrical Text Effect
- Custom Events in Objective-C
- Flash Arcade Preview
- Shape Tweening
- How To Install Adobe Flash Player 10.1 Beta In Ubuntu Linux
links
Similar Articles
- iPhone flash plugin
- videohamster
- flash player iphone 3g
- ipod videohamster com
- videohamster com
- how to install flash player on ipod touch
- flash circular menu tutorial as3
- videohamster iPhone
- flash player for iphone 3g
- how to install flash player on iphone
- flash player iphone 3gs
- video hamster
- Adobe Flash Player error: could not load cURL library
- ipod video hamster
- ipod videohamster
- how to install flash player on fedora 12
- flash plugin iphone
- Iphone flash support
- flash player for psp go
- flash cs4 gradient mask
- fedora chrome flash
- freebsd 8 firefox flash plugin
- animated background flash cs4
- fedora 12 chrome flash
- video hamster not working
- Adobe Flash Player for fedora 12
- chrome flash fedora
- circular flash clock
- flash cs4 sound tutorial
- flash player iphone
- install iphone flash plugin for safari browser
- flash plugin for iphone
- flash player for ipod touch
- ubuntu flash buttons not working
- flash count
- flashplayer-win xpi
- compile gnash 64-bit OR x64
- ubuntu 64 bit flash buttons not working
- flash cs4 alpha mask
- xpi archive of the flash player plugin
- iPhone videohamster com
- FreeBSD 8 flash 10
- fedora chrome flash
- gnash firefox
- how to install adobe flash player on fedora 12
- www iPod videohamster com
- flash timeline control
- how to click an option and display an image flash cs4
- generate thumb in flash
- click and reveal in flash
- videohamsterhqhd
- gradient mask in flash cs4
- plugin flash iPhone
- how to install flash player in fedora 12
- iPod videohamster com/
- npviewer button not clickable
- loadvariables as3
- psp flash player
- flash countdown timer
- 10 0 42 34 installed
- slackware firefox plugin directory
- flash chrome fedora
- freebsd 8 flash
- timer flash tutorial
- how to make youtube work on psp
- flash player on iphone 3g
- installing flash10 plugin
- flash cs4 alpha
- flash player for psp
- iphone 3gs flash player
- install flash on iphone
- flash player for iphone 3gs
- gradient mask flash cs4
- install flash player iphone 3g
- macromedia flash enabled psp
- fedora google chrome flash
- flash player fedora 12 chrome
- show text on mouseover in flash cs4
- how we can install a adobe flash playe on redhat linux
- XMLDataSource flash
- actionscript keyboardevent
- adobe flash player ubuntu chrome amd64
- ubuntu flash not clickable
- actionscript 3 color picker
- debian flash video
- chrome flash 10 ubuntu
- clearInterval as3
- flash as3 append text
- flash player for itouch 3g
- Agree and install now
- macromedia flash for iphone
- debian chrome flash
- actionscript 3 countdown 90 minutes
- Adobe Flash Player error could not load cURL library
- flash plugin for iphone
- iPhone 3g flash player
- colorpicker flash cs4
- install adobe flash player without administrator
- flash cs4 on click jump to frame
- adobe flash player for psp go
Active Posts
- adobe flash cs4 can`t assign actions to button
- AS3 saving movie clip as SWF file from flash
- AS3 saving movie clip as SWF file from flash
- utube cs4 flash
- movieclip scroller flash as2 free component
- flash cs3 movieclip containing dynamic text alpha
- centos flash sound
- 64bit flash chrome ubuntu
- animated button flash as2
- as3 popup PDF in new window
- as3 draw order
- play movie on mouse over flash as2
- flash cs4 how to set frame delay
- gotoandstop button onPress not working
- position 50 text field randomly in flash cs4
- 3D playlist for displaying videos
- flash cs4 how to set frame delay
- only show pictures in textfield htmlText
- how to install flash lite on sony ericsson
- videohamster
- how to import mp4 into flash cs4
- read text file using flash cs4
- open a swf file in AS3 with button
- scrollable background action script 3
- flash cs4 as3 button
- flash actionscript 3 0 clock
- comment installer adobe flash player sur fedora 12
- flash cs4 gradient alpha mask
- flash as3 scroll game
- as3 dynamic text mouse clicked
- flash cs4 as3 autoresize image
- flash actionscript 3 0 fade out buttons tutorial
- flash cs4 using query string from html
- flying randomly flash
- create movieclip cs4
- flash mask movieclip problem shape tween
- flas movie clip Scroll
- AS3 nature animation tutorial
- tuorial actionscript mousover
- freebsd 8 0 flash firefox
- stop drag
- actionscript 3 apply filter shadow text
- mp3 gap flash as3
- install flash plugin in chrome under ubuntu 9 10
- tutorial of flash cs3 for make navigation bar
- go to frame mouseevent flash cs4
- how to create swc file with flash cs4 movie player
- Keyboard event in Flash 8
- onClick Actionscript Button automate
- mouseoverflash amimated panel
- use keyboard flash as2 input field and enter
- movement controls actionscript code flash 3 0
- install flash 10 plugin firefox2 0 linux
- adobe flash player for nokia n81 mobile phones
- flash movieclip left right top bottom
- external classes not working in loaded clip AS3
- adobe flash cs3 button tutorial goto frame
- flash as3 hover
- flash cs4 button to save to hard drive
- install firefox java plugin without admin
- flash as2 variables to txt
- how to make a button disappear after clicking - flash 3 0
- as3 import color
- actionscript 3 xml menu
- text animation actionscript3 classes
- create xml thumb
- export ilustrator layers to flash cs4
- mouseover dynamic effects in flash
- Flash Action Scriopt 1 0 mouse up; mouse down; track
- After exporting an SWF from After Effects it doesnt loop?
- fscommand change embed height firefox
- add motion guide button in cs4 flash help
- mask blur show flash as3
- adobe flash player create mask start drag
- add tween to mouse motion
- opera flash itouch
- adding numbers in as3 tutorial
- countdown flash banner tutorial
- installing flash media player update on a citrix server
- stop() in the movie clip time line as3
