Flash MX 2004 MenuBar Component

  • TCStyle
  • Born
  • Born
  • TCStyle
  • Posts: 3
  • Loc: NY

Post 3+ Months Ago

I've just started to learn Flash's built in, UI components. I've managed to figure out how to use the ScrollPane, Button, MediaDisplay/Control, and Alert component, but I'm having trouble with the MenuBar component. I've searched the net and found nothing, posted on newgrounds fourm and got no answer, so I decided to ask you guys. Anyway, I found alittle script on the net I've been working with (on my main timeline):

stop();
var FileMenu = MainMenuBar.addMenu("Sound");
FileMenu.addMenuItem({label:"Adding Sound with AS", instanceName:"1"});
FileMenu.addMenuItem({label:"Starting&Stoping Sound", instanceName:"2"});
FileMenu.addMenuItem({label:"Changing Volume of Sound", instanceName:"3"});
var BuyMenu = MainMenuBar.addMenu("Components");
BuyMenu.addMenuItem({label:"Button", instanceName:"4"});
BuyMenu.addMenuItem({label:"Alert", instanceName:"5"});
BuyMenu.addMenuItem({label:"MenuBar", instanceName:"6"});
BuyMenu.addMenuItem({label:"ScrollPane", instanceName:"7"});
BuyMenu.addMenuItem({label:"MediaDisplay", instanceName:"8"});
BuyMenu.addMenuItem({label:"MediaController", instanceName:"9"});

All of that works fine, but I have no clue how to make it so that when you click one of the submenus, something happens. I'm kinda at a lose here, and have nowhere else to look. Any help would be greatly apperciated!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • KrakaJap
  • Born
  • Born
  • KrakaJap
  • Posts: 1

Post 3+ Months Ago

First you must declare your menu structures:

ex.
var menu1:Menu or var menu2:Object for a second tier sub menu

Then you need to define a listener object and pass this object to a function that will check for each menu option.

The problem here is that the first menu option needs to be defined and then referenced... the remaining menu options only need to be referenced so you will need two seperate functions.

ex.
var listenerObj = new Object();
listenerObj.change = function(evt){
switch (evt.menuItem){
case evt.menu.menuOption1: getURL("www.yahoo.com"); break;
}
}


Your second function will simply be a reference:

ex.
change = function(evt){
// remaining switch functions goes here for other menu items
}

Finally you need to initialize your listener objects:

ex.
menu1.addEventListener("change", listen);
menu2.addEventListener("change", this);
menu3.addEventListener("change", this);
etc. etc.

hope this helps.

BTW: you might want to place this actionscript within an actionscript file (filename.as) and include this file within your movies actionscript:

ex.
import mx.controls.Menu;
import mx.controls.MenuBar;
#include "filename.as"

This will effectively seperate your code from your flash, make it easier to edit, and provide general protection from decompilers.
  • snakemedia
  • Born
  • Born
  • snakemedia
  • Posts: 1
  • Loc: Germany

Post 3+ Months Ago

Hi I am new user in there... :D

I want to build an application.

Put a flash film.
I click the MenuBar > MenuItem --> When MenuItem calls into a new window-component.
How do I work? MenuItem can't to load / to call into Window- and Alert-component? :(

Please help me with good tutorial "MenuBar / MenuItem with Alert- and Window-Component"

I searched last 2 year i can not find the example for my sample: application.


Bye snakemedia
  • littlephoenix
  • Graduate
  • Graduate
  • User avatar
  • Posts: 147

Post 3+ Months Ago

hmm did you try flashkit ?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

@snakemedia : i have absolutely no idea what are you talking about.
if you can express in some simple steps what exactly you want to do, maybe someone will help you.
  • MusicGuru
  • Newbie
  • Newbie
  • MusicGuru
  • Posts: 14

Post 3+ Months Ago

IceCold wrote:
@snakemedia : i have absolutely no idea what are you talking about.
if you can express in some simple steps what exactly you want to do, maybe someone will help you.


i agree, its a bit hard to see what he means, but try flashkit for such scripts, or just read up on some forums and do a search on e.g v7n forum, i am sure you will find something

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 15 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.