Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Re: MX04 Menu component

Re: MX04 Menu component

2004-04-15       - By Scott Widmer

 Back
Reply:     1     2     3  

Nathan,

I don't know if you are just having trouble getting the menu to generate from
XML or just in general.  I took the code you provided and it does work.  I can
't
get it to work using XML either, but I don't know what a properly formatted
XML document looks like (does it need to start and end with <xml></xml>
respectively?).  The path to the XML document would replace "url" in the last
line (loader.load(url);) -- the path would need quotes around it.  However I
just
get an output error when I try to use that method instead of the one in lines
11
- 15 provided below.

I found this topice after being thoroughly frustrated with the lack of info
provided by Macromedia about how to implement the menu component,
myself.  I watched their intro to components presentation on their website and
had to laugh when they said components were designed to help those who
didn't know much about ActionScript.  I know a little, and I can't figure it
out.

Does anyone have a working example of something they did with the menu
component?  Something complete with a customized style and actions when
clicking on a menu item.  I can't seem to find a click event for a menu item in
the help either.

-Scott

--- In FLASHmacromedia@(protected), "Nathan Meyers" <
nmeyers@(protected)> wrote:
> Hi all.
> I'm trying to use the menu component in MX04, but I'm having absolutely
> no luck displaying my XML data through the menu. I have followed these
> steps in the Flash Help.
>  
> 1.           Select File > New and create a Flash document.
> 2.           Drag the Menu component from the Components panel to the
> Stage and delete it.
> This adds the Menu component to the library without adding it to the
> application. Menus are created dynamically using ActionScript.
> 3.           Drag a Button component from the Components panel to the
> Stage.
> Clicking button activates the menu.
> 4.           In the Property inspector, give the button the instance
> name commandBtn, and change its text property to Commands.
> 5.           In the Actions panel on the first frame, enter the
> following code to add an event listener to listen for click events on
> the commandBtn instance:
> 6.                var listener = new Object();
> 7.                listener.click = function(evtObj) {
> 8.                    var button = evtObj.target;
> 9.                  if(button.menu == undefined) {
> 10.                    // Create a Menu instance and add some items
> 11.                    button.menu = mx.controls.Menu.createMenu();
> 12.                    button.menu.addMenuItem("Open");
> 13.                    button.menu.addMenuItem("Close");
> 14.                    button.menu.addMenuItem("Save");
> 15.                    button.menu.addMenuItem("Revert");
> 16.                    // Add a change-listener to catch item selections
> 17.                    var changeListener = new Object();
> 18.                    changeListener.change = function(event) {
> 19.                  var item = event.menuItem;
> 20.                  trace("Item selected:  " + item.attributes.label);
> 21.                    }
> 22.                    button.menu.addEventListener("change",
> changeListener);
> 23.                }
> 24.              button.menu.show(button.x, button.y + button.height);
> 25.            }
> 26.            commandBtn.addEventListener("click", listener);
>  
>  
> The help then adds that one needs to add the following code to the first
> line of the timeline to reference your external XML file.
>  
> 1.        In the Actions panel, add the following code to the first
> frame to create a menu and add some items:
> 2.             var myMenu = mx.controls.Menu.createMenu();
> 3.             // Import an XML file
> 4.             var loader = new XML();
> 5.             loader.menu = myMenu;
> 6.             loader.ignoreWhite = true;
> 7.             loader.onLoad = function(success) {
> 8.               // When the data arrives, pass it to the menu
> 9.               if(success) {
> 10.              this.menu.dataProvider = this.firstChild;
> 11.            }
> 12.          };
> 13.          loader.load(url);
> Note: The menu items are described by the children of the XML document's
> first child.
> 14.     Select Control > Test Movie.
>  
> My XML file contains the following code.
>  
> <menu>
>     <menuitem label="MenuItem A" >
>       <menuitem label="SubMenuItem 1-A" />
>       <menuitem label="SubMenuItem 2-A" />
>     </menuitem>
>     <menuitem label="MenuItem B" >
>       <menuitem label="SubMenuItem 1-B" />
>       <menuitem label="SubMenuItem 2-B" />
>     </menuitem>
> </menu>
>  
> Now, my questions are; where do I insert the URL of my external XML
> file, and do I use both sets of code supplied by the Flash help (as
> above), or, do I just use the second set of code, or, do I combine code
> from both sets? I'm very confused :-(
>  
> Any help would be greatly appreciated, as would any examples from
anyone
> who has used this component, and I do apologize for the lengthy nature
> of this message.
>  
> Thanks, Nathan
>  
>
>
> [Non-text portions of this message have been removed]



-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Server geeks, take heart! If you're sick of wading through
animation & graphics instruction for relevant info., then
Nate Weiss' Macromedia Flash MX Professional 2004 for Server
Geeks is for you. Leave designing to designers and dig into
core concepts to create rich user interfaces, online
advertising, and more.  See www.peachpit.com for more info.
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/FLASHmacromedia/

<*> To unsubscribe from this group, send an email to:
    FLASHmacromedia-unsubscribe@(protected)

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/