# On (release) works on button, not on movieclip, why?

**URL:** https://forum.kirupa.com/t/on-release-works-on-button-not-on-movieclip-why/184642
**Category:** Uncategorized
**Created:** [April 6, 2006, 2:49pm UTC](https://forum.kirupa.com/t/on-release-works-on-button-not-on-movieclip-why/184642 "2006-04-06T14:49:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![leahgrace](https://avatars.discourse-cdn.com/v4/letter/l/f17d59/32.png) [@leahgrace](https://forum.kirupa.com/u/leahgrace)
#### Post date: [April 6, 2006, 2:49pm UTC](https://forum.kirupa.com/t/on-release-works-on-button-not-on-movieclip-why/184642/1 "2006-04-06T14:49:39Z")

</div>

I have a quiz where the user has multiple choice options. When the user selects the button, it checks to see if that is the correct answer for that question. If the answer is correct it jumps to a frame that plays a little animation and then tells it to go back to the beginning of the movie. At the beginning there is code that resets all the buttons and all the questions.

First I had simple buttons in my movie that had this code on them

```auto
on (release) {
 if (!hasAnswered) {
  currentQuizItem.checkAnswerNumber(1);
 }
 hasAnswered = true;
}

```

Then I decided that I wanted a more complex button, so I decided to replace the simple buttons with movieclips. The code on the movieclips is as follows which is supposed to do exactly what the button did, except I added a little piece that tells the movieclip instance to go to certain frame in the movieclip.

```auto
on (release) {
 if (!hasAnswered) {
  currentQuizItem.checkAnswerNumber(1);
  answer2Btn.gotoAndStop("checked")
 }
 hasAnswered = true;
}

```

Now, the movieclip button works for the first question of the quiz, but stops working after that. Why? All the buttons would reset properly. Why isn’t the movieclip??

This is the code for resetting everything when it goes back to the beginning. Note: The new questions and answers (being loaded from external xml file) do load, but something in the code that assigns the answer to the button isn’t working, b/c on the second question, the buttons no longer work, although they worked fine as simple buttons

```auto
var currentQuizItem = quizItems[currentQuestionNumber-1];
var hasAnswered = false;
question = currentQuizItem.getQuestion();
for (var i = 1; i<=currentQuizItem.getNumOfAnswers(); i++) {
 _root["answer"+i] = currentQuizItem.getAnswer(i-1);
 _root["answer"+i+"Btn"]._visible = true;
 _root["answer"+i+"Btn"].gotoAndStop("notChecked");
 _root["answer"+i+"Text"]._visible = true;
}
for (; i<=5; i++) {
 _root["answer"+i+"Btn"].gotoAndStop("notChecked");
 _root["answer"+i+"Btn"]._visible = false;
 _root["answer"+i+"Text"]._visible = false;
}
if (currentQuestionNumber<15) {
 questionType = "Knowledge Questions";
} else {
 questionType = "Behavior Questions";
}
stop();

```

---

<div class="post-metadata">

### Author: ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)
#### Post date: [April 6, 2006, 3:14pm UTC](https://forum.kirupa.com/t/on-release-works-on-button-not-on-movieclip-why/184642/2 "2006-04-06T15:14:09Z")

</div>

Well the code for a movieclip is slightly different. Also it doesn’t go on the symbol itself but on the timeline that contains the symbold. Typically it uses the form

```auto
NameOfClip.onRelease = function(){
//put code here
}

```

See if that fixes it?

---

<div class="post-metadata">

### Author: ![leahgrace](https://avatars.discourse-cdn.com/v4/letter/l/f17d59/32.png) [@leahgrace](https://forum.kirupa.com/u/leahgrace)
#### Post date: [April 6, 2006, 3:47pm UTC](https://forum.kirupa.com/t/on-release-works-on-button-not-on-movieclip-why/184642/3 "2006-04-06T15:47:48Z")

</div>

Oh my god! You’re my savior! Thank you sooooo much! I dont know why I didn’t try that!

---

<div class="post-metadata">

### Author: ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)
#### Post date: [April 6, 2006, 3:52pm UTC](https://forum.kirupa.com/t/on-release-works-on-button-not-on-movieclip-why/184642/4 "2006-04-06T15:52:13Z")

</div>

lol, glad it worked :thumb:
