4 Replies Latest reply: May 14, 2012 4:59 PM by Joselyn6 RSS

    Hello to all, Does any body could help me with a dropdownmenu?

    Joselyn6 Community Member

      I have a nav bar with several buttons with dropdownmenu each one this is my code:

       

       

      var navBtnGlow:GlowFilter = new GlowFilter(0x999999, 0.5, 0, 15, 1, 2, true, false);

      navBar_mc.addEventListener(MouseEvent.MOUSE_OVER, navOverF);

      navBar_mc.addEventListener(MouseEvent.MOUSE_OUT, navOutF);

       

       

      function navOverF(event:MouseEvent):void

      {

                event.target.filters = [navBtnGlow];

                navBar_mc.setChildIndex(event.target as MovieClip, 1);

                dropMenu_mc.gotoAndStop(navBar_mc.getChildAt(1).name);

      }

       

      function navOutF(event:MouseEvent):void

      {

                event.target.filters = [];

      }

       

      // this is the default swf load

       

      var Xpos:Number = 0;

      var Ypos:Number = 0;

      var swfWidth:Number = 450;

      var swfHeight:Number = 184;

      var swf:MovieClip;

      var loaderSWF:Loader = new Loader();

      precargador_mc.visible = false;

       

      var defaultSWF:URLRequest = new URLRequest("swfs/inicio.swf");

       

      loaderSWF.load(defaultSWF);

      loaderSWF.x = Xpos;

      loaderSWF.y = Ypos;

      loaderSWF.width = swfWidth;

      loaderSWF.height = swfHeight;

       

       

      addChild(loaderSWF);

      ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////

      I want that any button load a swf, I tried with this code, buy it does not works,

       

      // Btns Universal function

      function btnClick(event:MouseEvent):void {

       

                precargador_mc.visible = false;

                removeChild(loaderSWF);

                var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");

                loaderSWF.load(newSWFRequest);

                loaderSWF.x = Xpos;

           loaderSWF.y = Ypos;

           loaderSWF.width = swfWidth;

           loaderSWF.height = swfHeight;

                addChild(loaderSWF);

      }

      // Btn listeners

      navBar_mc.inicio_mc.addEventListener(MouseEvent.CLICK, btnClick);

      navBar_mc.quienes_mc.addEventListener(MouseEvent.CLICK, btnClick);

      navBar_mc.presentacion_mc.addEventListener(MouseEvent.CLICK, btnClick);

      navBar_mc.rests.addEventListener(MouseEvent.CLICK, btnClick);

      navBar_mc.cafes.addEventListener(MouseEvent.CLICK, btnClick);

      navBar_mc.servicios_mc.addEventListener(MouseEvent.CLICK, btnClick);

      navBar_mc.contacto_mc.addEventListener(MouseEvent.CLICK, btnClick);

       

      I hope it explain you my purpose, but now I was confuse cause exactly i don't remember if the names of the buttons has to the same names of the externs swfs.

      and if the "inicio_mc" for axample is a movie clip and I have to create a button like "cafes" ?

      thanks a lot for any help,

       

      Joselyn.

        • 1. Re: Hello to all, Does any body could help me with a dropdownmenu?
          Ned Murphy MVP

          You don't have to remember, your code tells you what your buttons' names need to be. 

           

          var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");

           

          The way you have the swf's being targeted requires that the buttons' names match the names of the swf files.  So if you are using "inicio_mc" as the button's instance name, then your swf file name would need to be inicio_mc.swf.  Likewise, if you swf file is named "inicio.swf, your button should be named "inicio"..

          • 2. Re: Hello to all, Does any body could help me with a dropdownmenu?
            Joselyn6 Community Member

            Hi Ned, Thanks very much for your great help, I developed this dropdownmenu from an example which it works perfect but when I want that it load some file swf, it doesn't works. This dropdownmenu is composed for a movie clip called navBar_mc and inside are the"buttons" movie clips and each one has one dropdownmenu displaying simbols of buttons, some of the "buttons" like "inicio" is considered just one button however I would like to know if this movie clip can receive buttons events to call an swf file, this is my confusion.

             

            mark out this error

             

            TypeError: Error # 1010: A term is undefined and has no properties.

            at menuDropDown_fla :: MainTimeline/frame1 ()

            Error # 2044: uncontrolled ioError: text = Error # 2035: Can not find the URL. URL:

             

             

            I have changed the names of the externs swfs still to match with each "button" the problem is when I down some button of the navBar_mc menu it does not load the swf extern.

             

            Well I appreciated as always any suggestion or advice.

             

            Lot Regards.

            Joselyn

            • 3. Re: Hello to all, Does any body could help me with a dropdownmenu?
              Ned Murphy MVP

              Use the trace function to find out which term is undefined.  Use the trace function to see what the url is that is not being found.

              • 4. Re: Hello to all, Does any body could help me with a dropdownmenu?
                Joselyn6 Community Member

                Hello Ned:

                 

                in others ocasions your helped was very helpful, but now, I was tried to learn of trace function, so anyway, I appreciated your help.

                 

                Thanks

                Joselyn