1

Hi there i am making a little game app via adobe flash and acs3 . I want to start the app then a movie clip appears , then i have some series of buttons on stage from which the user must select the one to match the object on screen with the button . Every time the user hits a button click from the buttons placed on stage, the object should change based on the correct (add 10 the score) or wrong(do not count) button click from user. So basically , i think a way to match the object spawned on screen with the buttons on screen ,is to take their x and y and if they match add on score and move on. ,Any ideas on how to make an object appear on specific x ,y on stage and then wait for the user to click and based on their x and y match or wrong? I can provide more info if someone has questions.

var score=1;
var gameTime:Number =20;
//stop();

var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, createNote); 
myTimer.start(); 

function createNote(evt:TimerEvent):void{
    var aNote:NoteF = new NoteF();
    aNote.y = 400; 
    //aNote.y = (Math.floor(Math.random() *100) + 400 );
    aNote.x = ( Math.floor(Math.random() *150) + 100 );
    aNote.addEventListener(MouseEvent.MOUSE_DOWN,hitme);
    gameTime--;

    addChildAt(aNote, 0);
    txtTime.text = gameTime.toString();
    if (gameTime <= 0){
    gotoAndStop(6);
    myTimer.stop();
    aNote.stop();
    }
}   

function hitme(event:MouseEvent){
    var ms:NoteF = new NoteF();
  ms.x = event.stageX;
    ms.y = event.stageY;
    //addChildAt(ms, 0);
    txtScore.text = Score++;
    event.target.parent.removeChild(event.target);
}


//set the array and fill in the notes for treble
var TrebleArray:Array=["C1","D1","E1","F1","G1","A","B","C","D","E","F","G","A1","B1"];
//then set up the listener for the button
PiannoKeys.addEventListener(MouseEvent.CLICK ,piannokeys);
function piannokeys(myEvent:MouseEvent){



    btnC.visible=false;
    btnD.visible=false;
    btnE.visible=false;
    btnF.visible=false;
    btnG.visible=false;
    btnA.visible=false;
    btnB.visible=false;


}

btnC.addEventListener(MouseEvent.CLICK,btnc);
stop();
//now the function called by the function listener
function btnc(myEvent:MouseEvent){

var currentNote:Number=Math.round(Math.random()*(TrebleArray.length-1));
//currentNote++;
txtFeedback.text=TrebleArray[currentNote];
}
paladino
  • 13
  • 3
  • What have you tried? Show your work thus far. – Neal Davis Mar 10 '17 at 16:32
  • i know its messy if someone can tell me how to properly paste code would be nice.:) i am also trying now with arrays instead , trying to generate an object from my library and then wait for user to press the button , if the button is the same as the array value add 10 to score and generate next random object on screen (from the array) , something like that, countdown times is also in . – paladino Mar 10 '17 at 17:22
  • Edit your post: paste you're code. Then select your code and click the `{}` button. – Neal Davis Mar 10 '17 at 17:37
  • ok done ! sry my late reply. i can provide any further explanation if you got any queries – paladino Mar 10 '17 at 18:23
  • Matching based on x and y? That seems like a hack to me and not very flexible. I see you are doing something with music. Can you explain what you actually want to match? Is it the note? The color? The image? Let's figure out a way to get them to match based on something more real. – Neal Davis Mar 10 '17 at 18:26
  • So basically i have a music note as an object , and based on that i created all my notes with different instant names like shown in the array on my code(C1 , D1 , E1 , F etc).When the user start the app , then selects the play option , he goes to frame 5 which is the current. There the user can see a drawn music stave , a timer and a score (dynamic textboxes) ,as well as buttons representing a note(eg btnB). The user also sees a note on the stave waiting for button matching, so its like sight reading the notes and try mathcing them with the buttons to aid them with their musical practice – paladino Mar 10 '17 at 18:35
  • omg, can you please rewrite your question to be more concise? You really don't need to tell us something like "I want to start the app..." is't quite obvious, don't you think? :) And after all that you said we (I) still don't know where is your problem? The question title says something about Movie Clip and score which suggest you have problem with displaying points. Then you talking something about placing movie clips on stage... and from the code and your comment we see you program is related to music - the fact there is term "musical score" is not helping to clarify what's your problem... – Paweł Audionysos Mar 14 '17 at 04:13

0 Answers0