mc inside mc inside mc insid.

  • maario
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

Hi there,

I've a button inside a movie clip, that is inside another movie clip, inside another movie clip, that just don't work.

On the root time line i put the code:

_root.menu_mc.fotos_mc.menuFotos_mc.wagon_mc.onRelease = function() {
_root.menu_mc.fotos2_mc.gotoAndPlay("show");
};

Can someone have an idea about why this don't work? I've not.

thanks.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

if you have onPress, onRelease, onRollOver, onRollOut on any of the movieclips that are parents to your button, then it won't work.
  • maario
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

Yes, probably that's it.
However, i've make it another way and it's resulting.

But i have another question for you Professor.
As you have already understood, i'm not an expert in action script, nor in any programming language.
However, i realy like action script. :wink:
So, can you tell me, how can i avoid that kind of Onassis testament?
I'm sure there's a way to optimize this...

Quote:
dif = 100;
avan = 95;
//passa os submenus todos para invisiveis e desactivados
_root.menu_mc.texto_mc.enabled = false;
_root.menu_mc.contactos_mc.enabled = false;
_root.menu_mc.menuFotos_mc.enabled = false;
_root.menu_mc.fotos_mc.enabled = false;
_root.menu_mc.texto_mc._visible = false;
_root.menu_mc.contactos_mc._visible = false;
_root.menu_mc.menuFotos_mc._visible = false;
_root.menu_mc.fotos_mc._visible = false;
//movimento da página
_root.onEnterFrame = function() {
if (_root.menu_mc.fotos_mc.enabled == true) {
_root.menu_mc._x = (-450/Stage.width*_xmouse)+avan;
_root.menu_mc._y = (-10/Stage.height*_ymouse)+239;
} else {
_root.menu_mc._x = (-dif/Stage.width*_xmouse)+avan;
_root.menu_mc._y = (-10/Stage.height*_ymouse)+239;
}
};
//ao clicar nos botões do menu
_root.menu_mc.textoBtn_mc.onRelease = function() {
this.enabled = false;
_root.menu_mc.texto_mc.enabled = true;
_root.menu_mc.texto_mc._visible = true;
};
_root.menu_mc.fotosBtn_mc.onRelease = function() {
this.enabled = false;
_root.menu_mc.menuFotos_mc.enabled = true;
_root.menu_mc.menuFotos_mc._visible = true;
};
_root.menu_mc.contactosBtn_mc.onRelease = function() {
this.enabled = false;
_root.menu_mc.contactos_mc.enabled = true;
_root.menu_mc.contactos_mc._visible = true;
};
//ao clicar no menu das fotos
_root.menu_mc.menuFotos_mc.wagonBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
_root.menu_mc.menuFotos_mc.maratBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
_root.menu_mc.menuFotos_mc.viktBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
_root.menu_mc.menuFotos_mc.spidBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
_root.menu_mc.menuFotos_mc.visBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
_root.menu_mc.menuFotos_mc.outrBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
_root.menu_mc.menuFotos_mc.poneiBtn_mc.onRelease = function() {
_root.menu_mc.fotos_mc.enabled = true;
_root.menu_mc.fotos_mc._visible = true;
};
//botões para fechar
_root.menu_mc.menuFotos_mc.closeFotos_mc.onRelease = function() {
_root.menu_mc.menuFotos_mc._visible = false;
_root.menu_mc.menuFotos_mc.enabled = false;
_root.menu_mc.fotos_mc._visible = false;
_root.menu_mc.fotos_mc.enabled = false;
_root.menu_mc.fotosBtn_mc.enabled = true;
};
_root.menu_mc.contactos_mc.closeContactos_mc.onRelease = function() {
_root.menu_mc.contactos_mc._visible = false;
_root.menu_mc.contactos_mc.enabled = false;
_root.menu_mc.contactosBtn_mc.enabled = true;
};
_root.menu_mc.texto_mc.closeTexto_mc.onRelease = function() {
_root.menu_mc.texto_mc._visible = false;
_root.menu_mc.texto_mc.enabled = false;
_root.menu_mc.textoBtn_mc.enabled = true;
};


Thanks for all.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

when you have many buttons and each one does something else, there's not too much to do about it.
But in your case, use a function for all your menu items.
Code: [ Select ]
// first part of code remains the same
function EnableFotosMC(bEnable)
{
_root.menu_mc.fotos_mc.enabled = bEnable;
_root.menu_mc.fotos_mc._visible = bEnable;
}

_root.menu_mc.textoBtn_mc.onRelease = _root.menu_mc.fotosBtn_mc.onRelease = _root.menu_mc.contactosBtn_mc.onRelease = function()
{
   this.enabled = false;
   EnableFotosMC(true);

}
_root.menu_mc.menuFotos_mc.wagonBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.maratBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.viktBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.spidBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.visBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.outrBtn_mc.onRelease = EnableFotosMC(true);

// the rest remain the same ...
  1. // first part of code remains the same
  2. function EnableFotosMC(bEnable)
  3. {
  4. _root.menu_mc.fotos_mc.enabled = bEnable;
  5. _root.menu_mc.fotos_mc._visible = bEnable;
  6. }
  7. _root.menu_mc.textoBtn_mc.onRelease = _root.menu_mc.fotosBtn_mc.onRelease = _root.menu_mc.contactosBtn_mc.onRelease = function()
  8. {
  9.    this.enabled = false;
  10.    EnableFotosMC(true);
  11. }
  12. _root.menu_mc.menuFotos_mc.wagonBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.maratBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.viktBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.spidBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.visBtn_mc.onRelease = _root.menu_mc.menuFotos_mc.outrBtn_mc.onRelease = EnableFotosMC(true);
  13. // the rest remain the same ...


another thing you could do, would be to load the menu either from a hardcoded array or from an xml file, and create it dynamic, thus you will have:
Code: [ Select ]
for (iMainMenuIndex = 0; iMainMenuIndex <nMainMenuCount; iMainMenuIndex ++)
{
 crtMainMenu = _root.menu_mc.mainMenu[iMainMenuIndex];
 for (iMenuItemIndex = 0; iMenuItemIndex<nMenuItemCount; iMenuItemIndex++)
 {
   crtMainMenu.menuItem[menuItemIndex].onRelease = function()
    {
        // function code here
    }
   
 }
}
  1. for (iMainMenuIndex = 0; iMainMenuIndex <nMainMenuCount; iMainMenuIndex ++)
  2. {
  3.  crtMainMenu = _root.menu_mc.mainMenu[iMainMenuIndex];
  4.  for (iMenuItemIndex = 0; iMenuItemIndex<nMenuItemCount; iMenuItemIndex++)
  5.  {
  6.    crtMainMenu.menuItem[menuItemIndex].onRelease = function()
  7.     {
  8.         // function code here
  9.     }
  10.    
  11.  }
  12. }

There are lots of things you could do ... you just need to practice more.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 4 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.