Skip to main content
Inspiring
December 4, 2006
Answered

apply one function to muliple movieclips

  • December 4, 2006
  • 3 replies
  • 434 views
I've got 24 movieclips which I'm using as buttons. The first frame is labeled "up", the second is labeled "over", etc. Question: instead of having to write this 24 times:

mybutton1.onRollOver = function(){
this.gotoAndStop("over");
}
is there a way to apply this RollOver action to all 24 buttons in a more parsimonious way? I tried this:

mybutton1 = mybutton 2.onRollOver = function(){
this.gotoAndStop("over");
}

but that doesn't work. Help is much appreciated!

Michael
This topic has been closed for replies.
Correct answer jonnybennett
try:::

mybutton1.onRollOver=mybutton2.onRollOver = function(){
this.gotoAndStop("over");
}

3 replies

Participant
December 5, 2006
Can you help me - I have some movie clips that I want to use as buttons and when the button is clicked it plays another movie can you tell me how to do that or send me a flash file or link to see how it looks - I think that I am wanting the same thing as you are doing. thanks for any help
Inspiring
December 7, 2006
toot123,

If you want your movieclip button to play another movie then you either want to use loadMovie (which would load in an external swf file), or attachMovie (which attaches a movieclip to your stage). Which one of those are you looking to do?
Inspiring
December 4, 2006
or...

for(var i=0; i<=24; i++)
{
this["mybutton"+i].onRollOver = function()
{
this.gotoAndStop("over");
}
}
Inspiring
December 5, 2006
Yes, that works too. Even more elegant. Thanks!

Michael
jonnybennettCorrect answer
Inspiring
December 4, 2006
try:::

mybutton1.onRollOver=mybutton2.onRollOver = function(){
this.gotoAndStop("over");
}
Inspiring
December 4, 2006
Yup. That did it. Thanks so much!!