PDA

View Full Version : Movie clip instances


micheal
12-05-2001, 09:05 AM
I am very new to Flash and am having trouble understanding Library items and movie clip instances.

What I have done is created 4 different movie clips that represent 4 different checkboxes (and they work!!). I am using them all on a frame to act as a way for the user to answer one of 4 questions. I have set a seperate variable within each checkbox that will tell me at the end of the quiz which button they pressed.

The above all works fine on this frame, however I have lots of other questions that need to be answered that are on different frames so I though that I could drag an instance of the checkbox movieclips from the library and then edit the variable name (i.e change it to qu2) so that the same checkboxes could be used time and again with slight editing (isn't this the OO philosophy??).

The problem that occurs is when I edit the variable name it changes it for every instance of the checkbox throughout the movie!!! - which is pretty much useless.

Does anyone know what I am doing wrong??

Ricod
12-05-2001, 09:28 AM
If u declare the variable on the movieclip, and u change it there, U'll change it everywhere, since u changed the library instance. Add the variable instead of renaming it on yer timeline. So you'll get something like :

_root:answer1 = _root:givenAnswer;
_root:answer2 = _root:givenAnswer;

And change _root:givenAnswer through the buttons.
So you'll get a :
on (release){
_root:givenAnswer = "B";
}
etc.

But u may want to drag instances of yer button on the timeline where u placed the question, not an MC which contains the button.

And after yer fed up with the whole _root:answer1 etc. take a look at the arrays tutorial to learn about arrays and better methods to declare stuff. But all in due time.