Try to get a menu drop-down multilayer to work

Hello

I'm experimenting with to get a menu to drop down in two stages. The menu must be generated from XML, and the menu is supposed to be structured as follows, with menu items that appear when rolling on the menu item in the root and sub menu items apprearin when rolling on the menu item in the menu.

Root Menu itemThe main menuSub Menu Item A1


Sub Menu Item A2

B main menuSub Menu Item B1

Everything seems to work well, except that the root and hand are still visible. The idea is to show the main menu invisible by declaring "rootcontainer.visible = false" in the code below... but it doesn't seem to work, so that the "container.visible = false" in the deepest of loop do its work. If anyone has information as to where I should be looking, that would make me very grateful.

import flash.net.URLLoader;

import flash.net.URLRequest;

import flash.events.Event;

var xPos:Number = 0;

var yPos:Number = 0;

var yPosSub:Number = 0;

var yPosRoot:Number = 0;

var texts2:XML;

var myLoader:URLLoader = new URLLoader();

var request: URLRequest = new URLRequest ("texts2.xml");

myLoader.load (request);

myLoader.addEventListener (Event.COMPLETE, loadMenu);

function loadMenu(event:Event)

{

texts2 = new XML (event.target.data);

myLoader.removeEventListener (Event.COMPLETE, loadMenu);

for each (var rootnode:XML in texts2.root)

{

var menuRoot:MovieClip = new menu_root();

menuRoot.buttonMode = true;

menuRoot.href = rootnode. @ href.

menuRoot.label_txt.selectable = false;

menuRoot.label_txt.mouseEnabled = false;

menuRoot.label_txt.text = rootnode. @ name;

menuRoot.y = yPosRoot;

yPosRoot += menuRoot.height;

var rootcontainer:Sprite = new Sprite();

rootContainer.y = menuRoot.height;

rootContainer.Visible = false;

yPos = 0;

for each var node: XML (in rootnode.menu)

{

var menuMC:MovieClip = new menu_mc();

menuMC.buttonMode = true;

menuMC.href = node. @ href.

menuMC.label_txt.selectable = false;

menuMC.label_txt.mouseEnabled = false;

menuMC.label_txt.text = node. @ name;

menuMC.x = menuRoot.width;

menuMC.y = yPos;

yPos += menuMC.height;

var container: Sprite = new Sprite();

Container.y = menuMC.height;

Container.Visible = false;

yPosSub = 0;

for each var subnode: XML (in node.submenu)

{

var linkMC:MovieClip = new link_mc();

linkMC.buttonMode = true;

linkMC.x = menuMC.width;

linkMC.y = yPosSub - menuMC.height;

linkMC.href = subnodes. @ href.

linkMC.label_txt.text = subnodes. @ name;

linkMC.label_txt.mouseEnabled = false;

container.addChild (linkMC);

yPosSub += linkMC.height;

}

container.graphics.beginFill (0 x 000000, 0);

container.graphics.drawRect (0, 0, container.width + 1, container.height + 1);

container.graphics.endFill ();

menuMC.addChild (container);

addChild (menuMC);

menuMC.addEventListener (MouseEvent.ROLL_OVER, _rollOverHandler);

menuMC.addEventListener (MouseEvent.ROLL_OUT, _rollOutHandler);

menuMC.addEventListener (MouseEvent.CLICK, _mouseClickHandler);

}

rootcontainer.graphics.beginFill (0 x 000000, 0);

rootcontainer.graphics.drawRect (0, 0, rootcontainer.width + 1, rootcontainer.height + 1);

rootcontainer.graphics.endFill ();

menuRoot.addChild (rootcontainer);

addChild (menuRoot);

menuRoot.addEventListener (MouseEvent.ROLL_OVER, _rollOverHandlerRoot);

menuRoot.addEventListener (MouseEvent.ROLL_OUT, _rollOutHandlerRoot);

menuRoot.addEventListener (MouseEvent.CLICK, _mouseClickHandlerRoot);

}

}

function _rollOverHandler(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = true;

}

function _rollOutHandler(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = false;

}

function _mouseClickHandler(event:MouseEvent):void

{

trace (Event.Target.href);

}

function _rollOverHandlerRoot(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = true;

}

function _rollOutHandlerRoot(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = false;

}

function _mouseClickHandlerRoot(event:MouseEvent):void

{

trace (Event.Target.href);

}

Nevermind, got it to work... After drawing some diagrams, I realized that I had added to the children in all the wrong places. If anyone is interested:

import flash.net.URLLoader;

import flash.net.URLRequest;

import flash.events.Event;

import flash.display.MovieClip;

var xPos:Number = 0;

var yPos:Number = 0;

var yPosSub:Number = 0;

var yPosSubSub:Number = 0;

var texts4:XML;

var myLoader:URLLoader = new URLLoader();

var request: URLRequest = new URLRequest ("texts4.xml");

myLoader.load (request);

myLoader.addEventListener (Event.COMPLETE, loadMenu);

function loadMenu(event:Event)

{

texts4 = new XML (event.target.data);

myLoader.removeEventListener (Event.COMPLETE, loadMenu);

for each var node: XML (in texts4.menu)

{

var menuMC:MovieClip = new menu_mc();

menuMC.buttonMode = true;

menuMC.href = node. @ href.

menuMC.label_txt.selectable = false;

menuMC.label_txt.mouseEnabled = false;

menuMC.label_txt.text = node. @ name;

menuMC.y = yPos;

yPos += menuMC.height;

var container: Sprite = new Sprite();

Container.y = menuMC.height;

Container.Visible = false;

yPosSub = 0;

for each var subnode: XML (in node.submenu)

{

var linkMC:MovieClip = new menu_mc();

linkMC.buttonMode = true;

linkMC.x = menuMC.width;

linkMC.y = yPosSub - menuMC.height;

linkMC.href = subnodes. @ href.

linkMC.label_txt.text = subnodes. @ name;

linkMC.label_txt.mouseEnabled = false;

container.addChild (linkMC);

yPosSub += linkMC.height;

var subcontainer: Sprite = new Sprite();

Subcontainer.y = linkMC.height;

Subcontainer.Visible = false;

yPosSubSub = 0;

for each (var subsubnode:XML in subnode.subsubmenu)

{

var sublinkMC:MovieClip = new menu_mc();

sublinkMC.buttonMode = true;

sublinkMC.x = linkMC.width;

sublinkMC.y = yPosSubSub - linkMC.height;

sublinkMC.href = subsubnode. @ href.

sublinkMC.label_txt.text = subsubnode. @ name;

sublinkMC.label_txt.mouseEnabled = false;

subcontainer.addChild (sublinkMC);

yPosSubSub += linkMC.height;

}

linkMC.addChild (subcontainer);

container.addChild (linkMC);

linkMC.addEventListener (MouseEvent.ROLL_OVER, _rollOverHandler2);

linkMC.addEventListener (MouseEvent.ROLL_OUT, _rollOutHandler2);

linkMC.addEventListener (MouseEvent.CLICK, _mouseClickHandler2);

}

menuMC.addChild (container);

addChild (menuMC);

menuMC.addEventListener (MouseEvent.ROLL_OVER, _rollOverHandler);

menuMC.addEventListener (MouseEvent.ROLL_OUT, _rollOutHandler);

}

}

function _rollOverHandler(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = true;

}

function _rollOutHandler(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = false;

}

function _mouseClickHandler(event:MouseEvent):void

{

trace (Event.Target.href);

}

function _rollOverHandler2(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = true;

}

function _rollOutHandler2(event:MouseEvent):void

{

event.currentTarget.getChildAt (2) .visible = false;

}

function _mouseClickHandler2(event:MouseEvent):void

{

trace (Event.Target.href);

}

Tags: Adobe Animate

Similar Questions

  • Try to change the menu drop-down

    I created a form that uses a lot of drop-down menus and trying to get the menu drop-down see the descriptions and have actually filled area with a number of coin instead of the description. I am not against XML encoding if necessary I am new to it but played around a little bit. Ideas or direction would be greatly appreciated thanks.

    Yes. To descriptions in the menu drop down and then specify values in the binding tab. In the event for the menu output drop-down put the code (in formcalc):

    If ($.rawValue == 1) then

    $.formattedValue = "109323" / / put all part number is here

    ElseIf ($.rawValue == 2) then

    $.formattedValue = "109324" / / etc

    endif

    the rawValue is the value of the option, the person has chosen in the menu and the formattedValue is what the box displays the exit event has run.

  • Spry menu drop-down does not work in internet explore

    Hi guys, I have a problem with my menu drop-down. Please help me

    1. I already use spry menu bar 2.0. It works in firefox but not in internet explore.  It is said: "internet explore restricts this form of running scripts or Xcontrol active Web page.
    2. I want to make the spry menu to be "liquid". I mean when I restore down the window of firefox or internet explorer, it will automatically change size. I want to like it so that size it can look also into ipad or pc.

    Thank you for your help

    For some, I don't understand why that is to say the berms when you try to run a script from a local file. As a general rule, if you need to download the file, then download in IE, it works without problem.

    This page should help...

    imations http://www.troublefixers.com/Disable-ActiveX-Warning-in-Internet-Explorer-while-Playing-an.

  • * URGENT * buttons within a menu "drop-down" don't work well...?

    I have a 'drop down menu ' (which is in fact silent...) with 4 buttons on the inside. The menu BG is just a movieclip containing the buttons. The problem is, when you hover over a button of the menu drop-down retracts. How do I get flash to examine the buttons to be part of the background, so he doesn't think you're mousing on when you hover over the buttons?

    Here is a link to the FLA and the code. Any help is greatly appreciated! I tried to make it work for more than five hours and I'm extremely frustrated.
    FLA:
    http://www.mediafire.com/?hro25c9sbfrd4wc

    Code:
    http://pastebin.com/nUG6mrVP

    The berries are unnecessary because 1) they have scope in functions 2) you create a new one for each tween.  If this code from a tutorial, you'll do yourself a favor to abandon the one who wrote it in the future.  It might be that you just revised the code without knowing how it should be done given that other aspects of your code that are simply false as well.  Change the following and see if it works...

    Import fl.transitions.Tween; you only need to import once
    Fl.transitions.easing import. *;
    Import fl.transitions.TweenEvent;

    var menuTween:Tween;  declared outside any function interpolation

    flooringMenuBG.addEventListener (MouseEvent.ROLL_OVER, fl_MouseOverHandlerIn);

    function fl_MouseOverHandlerIn(event:MouseEvent):void
    {
    menuTween = new Tween(flooringMenuBG,'y',Back.easeOut,170,90,8,false);
    }

    var fM_listenerOut = flooringMenuBG.addEventListener (MouseEvent.ROLL_OUT, fl_MouseOverHandlerOut);

    function fl_MouseOverHandlerOut(event:MouseEvent):void
    {
    menuTween = new Tween(flooringMenuBG,'y',Strong.easeIn,90,170,10,false);
    }

  • When I right click on the desktop I no lnger didn't get the menu drop-down normal.

    Y at - it a shortcut or another way to trigger this menu, or repair my right click?

    Hello

    ·         You will remember to do recent changes on the computer before this problem?

    ·         What exactly happens when you right click?

    I would say that are you talking about follow the steps below:

    Method 1:

    Run the System File Checker tool to troubleshoot missing or corrupted system files.  Follow the steps in the link:

    http://support.Microsoft.com/kb/929833

    Method 2:

    If the previous step fails, create new user account. Follow the steps in the link:

    http://Windows.Microsoft.com/en-us/Windows-Vista/create-a-user-account

  • When I right click on the desktop and get the menu drop down and go again, the 'Record' option is not available. How can I get that back?

    I tried to solve this problem with "Folder Options" in the control panel of Windows 7 but I did help and I "' reset all the original settings, which did not help either.

    I can't create new folders in any other folder either. Even the "New folder" option in the toolbar does not have what it is supposed to do, namely to create a new folder.

    You have installed chrome? It's looking like a recent update of chromium may be the cause. Here are two patches.

    How to remove and restore the default context Menu items 'New' in Windows 7 and Windows 8
    http://www.SevenForums.com/tutorials/28677-new-context-menu-remove-restore-default-menu-items.html

    If still no joy, see the 'response' by Linda Yan in this thread.
    http://social.technet.Microsoft.com/forums/en-us/w7itprogeneral/thread/97de8a2a-12f2-4381-A409-a78f4ae551cf/#99395761-56de-4a76-8C2A-eab498ad735a

    Tip: When you save the text in Notepad, the default file format is .txt. Replace all files.

  • Is there a way to return to the menu drop-down button "return"?

    It's a giant pain click back several times when before I could just look in the menu to find the page I wanted to come back.

    Is there a way to do this somewhere else perhaps?

    You can get the menu drop-down by clicking on the previous/next buttons or now the left key pressed until the list is displayed.

    If you want the drop-down arrow, you can add it with the add-on of dropmarker rear - https://addons.mozilla.org/firefox/addon/backforward-dropmarker

  • Y at - it an option to activate the menu drop-down overview of the policies?

    Until about a week ago, I could type in the menu and the box of selection taking place and I could select fonts. (as in the image below) Now, it only goes to the exact police that I type, and there is no drop down with it. It's really make things more difficult for me. I can get the menu drop-down appears, but only if I click on the arrow and use the mouse. The second, that I start typing it disappears.

    Does anyone know how to recover my preview? I'm worried that I hit a weird keyboard shortcut.

    Untitled.jpg

    There are two search modes. Maybe you changed it. Read about it in this article.

    New features of Illustrator CC Type | Design of Type and layout in Adobe Illustrator | Peachpit

  • left menu quich launch menu drop-down

    Hello

    just loaded a CS5 demo version and loaded on my windows 7 64 bit quadcore system which has 8 GB of memory,

    In my copy of photoshop when I click on the rectangle tool (menu bar on the left of the screen) I get a menu drop-down offering me circles etc.

    However in Illustrator I have not. I doo see arrow (bottom right of the box), but I have no had a drop-down.

    Any ideas?

    Thank you

    Ian

    You must click and hold for a second. If it does not show, just hold out a little longer.

  • When I pick up my brush tool and try to get a soft brush on the menu drop-down they look all white people, I

    When I pick up my brush tool and try to get a soft brush in the dropdown menu drop-down they look all white people, I don't see a soft brush of a soft brush No. How can I fix it in photoshop? Thank you

    Hi tvilela,

    Do you, by chance, the pencil selected instead of the Brush tool.

    -Christmas

  • How can I get a program icon for the office high back on the menu drop-down?

    I accidentally pulled the icon 'Windows Explorer' on the menu drop-down 'Programs' (instead of create a shortcut).  Now I can not understand how to get it back.  If I display the menu drop-down then try to sneak back, as soon as I click the icon, the menu drop down disappears.

    This should do it:

    1. Click the Start button.
    2. Click Open .
    3. Click programs .
    4. Click on Accessories .
    5. Drag the icon into the folder.

    Boulder computer Maven
    Most Microsoft Valuable Professional

  • BlackBerry Z10 menu drop-down ("Notifications", "Alarm") disappears!

    My z10 works beautifully.

    Except in the last days whenever I do the drop-down list active (the one accessible by sliding from senior management downwards) and try to click "Alarm" or "Notifications", the menu drop down menu scans back and disappears!

    In other words, it seems that * just * these two buttons (alarm and Notifications) are disabled, so the effect is the same, as if I was to click on the black background of the drop in the menu drop-down or anywhere else but an active button. By pressing the buttons or notifications in all sorts of ways has the same effect: the banner just think you want to exit the menu and disappears.

    Any ideas why this happens? Am I the only one?

    I had to return the phone and get a new one.

  • Menu drop-down list does not apear, instead of this, there is a miniature version of the Thunderbird window. How to fix?

    On a new installation of Thunderbird running on a new instalation of Windows 7 in the dropdown menu will not work. By clicking on the list of the menu drop-down appears, but instead to be filled with tryies to squeez options in a copy of the window full thunderbid - see the screenshot.

    Restart in SafeMode it works OK.

    Any ideas how to fix?

    No picture, but try this
    https://support.Mozilla.org/en-us/questions/1012145

    Not better?

  • menu drop-down icons sparkle and cannot be read

    for the latest versions of several menu drop downs and pitchers will stay visible long enough to read the ads and make a choice. Is there a setting that I can't find?

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

    Try turning off hardware acceleration.

    • Tools > Options > advanced > General > Browsing: "use hardware acceleration when available.

    If disable hardware acceleration works then check if there is an update available for your graphics display driver.

  • "When I click on: Favorites" menu drop-down will remain visible. It flashes and the.

    When I click on 'Favorites' from the menu drop-down flashes momentarily and is therefore not visible. If I hover over the list, each bookmark flashes momentarily and then not be visible. The list is actually still there because when I go to where it should be, the hyperlink is displayed in the lower left corner of the window.

    In Firefox 4 and later Safe mode disables extensions and disables hardware acceleration.

    Try turning off hardware acceleration.

    • Tools > Options > advanced > General > Browsing: "use hardware acceleration when available.

    If disable hardware acceleration works then check if there is an update available for your graphics display driver.

Maybe you are looking for

  • DeskJet 2545: DeskJet 2545 Google Cloud Print

    I am having major problems trying to get my new DeskJet 2545 with Google Cloud Print configuration.  From what I can find online, it seems that it can not support it yet.  The only reason why I bought this model is because it says here on the "Google

  • Error 0x800488FB and cannot send or receive messages for the hotmail account.

    Original title: error 0x800488FB Can't send or receive messages for the hotmail account (xyz) 9x800488FB Server error Server "http://mail.services.live.com/DeltaSync_v2.0.0/Sync.aspx" Windows Live Mail error ID: 0x800488FB I think my account has been

  • Startup problem Acer e1 linux 510 model

    I bought acer aspire model E1 510 with linux preinstall. I want to install windows 7 or windows 8 inside. But he has only UEFI boot mode option in the bios. (no mode legecy). I can't start fron dvd rom

  • Account settings export & import Outlook

    How do I export my account settings Outlook 2007 my old XP pro PC to a new Win7PC with Outlook 2007

  • Reinstallation of Win7 with disc to update only

    Hi, I just bought a new Barebone PC (motherboard, processor and RAM only) with the intention to format my current hard drive and use them in the new system. However, my Windows 7 installation disc is one of these single upgrade and specifies that mus