OOP Query (movie clips)

Hello folks,

This is my first post here. I have recently started learning OOP programming in flash and have also gone through the brilliant tutorial at Kirupa.

I have a query regarding OOP and Movieclips and custom classes (something I haven’t been able to get the hang of). I will try and demonstrate my question with an example (I can’t think of how else to explain it). :sigh:

Please do respond to it:

  1. I have created a custom class with a variables and a function

function myNote(myNumber){

var myNumber;

  1. I have then added a prototype of the movieClip class

myNote.prototype = new MovieClip();

  1. Created another function

myNote.prototype.onMouseUp = function(){
trace("The number of the note you have clicked is: "+ this.myNumber);

  1. Finally I have registered the custom class with a movieclip in the library

Object.registerClass(“note”, myNote);

  1. Then I create a few instances of the movieClip on stage
    attachMovie(“note”, ‘n0’, 100, {myNumber: ‘1’});
    attachMovie(“note”, ‘n1’, 101, {myNumber: ‘2’});
    attachMovie(“note”, ‘n2’, 102, {myNumber: ‘3’});


Now that I have three instances of the movieClip on the stage, so when I click on any of them, the function (onMouseUp…) is summonded and the number (myNumber) of the movie clip is traced in the output window.

But instead of showing the number of the movieClip i clicked on, I get the numbers of ALL the movieclips on stage.

Why is the function running for all the movieclips on stage? Where am I going wrong? :puzzle:

You see ultimately I would like that whichever movieClip i click on, it should change a varibale flag (which will be defined in the class) to activated, but if I face the above problem, then all movieclips will have their flag values changed to activate irrespective of which i click on.


Thank you,