Skip navigation
Currently Being Moderated

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

May 2, 2012 11:18 PM

Tags: #as3

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.

 
Replies
  • Currently Being Moderated
    May 3, 2012 8:15 AM   in reply to Joselyn6

    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"..

     
    |
    Mark as:
  • Currently Being Moderated
    May 7, 2012 4:21 AM   in reply to Joselyn6

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points