Hi,
I’m creating a DDR style game. The ‘moving graphics’ are being randomly and dynamically created with the default instance name (instance28, instance 30…) I want to be able to refer to these different elements according to another movie clip I press (in this case, they look like piano keys).
So, if a ‘C’ moving graphic is created, I want the C movie_clip with a listener attached to check the ‘C’ moving graphic.
stop();
//random notes
var noteTimer = 0;
var note;
stage.addEventListener(Event.ENTER_FRAME, frameTrigger);
function frameTrigger (evt:Event) {
//randomly spawn notes
noteTimer++;
if (noteTimer == 10) {
//make a random number
var ranNum:Number = Number(Math.round(Math.random() * 2));
if (ranNum == 0) {
//rest
trace("rest");
}
else if (ranNum == 1) {
//snowflake 1
note = new Csign();
trace("Csign");
} else if(ranNum == 2) {
//snowflake 2
note = new Dsign();
trace("Dsign");
}
note.x = 685;
note.y = 353;
addChild(note);
noteTimer = 0;
trace(note.name);
}
}
//piano note listeners
C_mc.addEventListener(MouseEvent.CLICK, playC);
Csharp_mc.addEventListener(MouseEvent.CLICK, playCsharp);
D_mc.addEventListener(MouseEvent.CLICK, playD);
//button modes
C_mc.buttonMode = true;
Csharp_mc.buttonMode = true;
D_mc.buttonMode = true;
//functions for listeners
function playC (evt:MouseEvent):void {
trace(“C”);
/if (note.x > 200 && note.x < 300){
trace(“well done”);
} else {
trace(“bad!!”)
}/
C_mc.gotoAndPlay(2);
}
function playCsharp (evt:MouseEvent):void {
trace(“C#”);
Csharp_mc.gotoAndPlay(2);
}
function playD (evt:MouseEvent):void {
trace(“D”);
D_mc.gotoAndPlay(2);
}
Any help is appreciated!