Flash programming for my Social Tone Matrix

Hooray! My project is working. Flash is looping through each column, on a 1 second timer, checking for keypresses. When it finds an active one, it checks its position.

At the moment it’s just tracing the key, all I need now is to make it generate the tone instead.


My code is below:

var rowcount:int = 1;
var myTimer:Timer = new Timer(1000); // 1 second
myTimer.addEventListener(TimerEvent.TIMER, SecondsPassed);

myTimer.start();

function SecondsPassed(event:TimerEvent):void {
//trace(“SecondsPassed() called @ ” + getTimer() + ” ms”);

trace (“On row number ” +rowcount);
if (rowcount==8)
{rowcount=0;
trace (“__________________”);
}

checkrow(rowcount);
rowcount++;
}

function checkrow(rowcount) {
if (rowcount==1){
trace (“Checking row 1″);
stage.addEventListener (KeyboardEvent.KEY_DOWN, detectKeypress);

function detectKeypress (myevent:KeyboardEvent):void {
trace (“There’s a keypress going on.”);
if (myevent.keyCode==81){
// Q was pressed
trace (“Q is pressed”)};
if (myevent.keyCode==79){
// O was pressed
trace (“O is pressed”)};
if (myevent.keyCode==74){
// J was pressed
trace (“J is pressed”)};
if (myevent.keyCode==81){//edit /
// / was pressed
trace (“/ is pressed”)};
if (myevent.keyCode==113){
// q was pressed
trace (“q is pressed”)};
if(myevent.keyCode==97){
// a was pressed
trace (“a is pressed”)};
if(myevent.keyCode==112){
// a was pressed
trace (“a is pressed”)};
if(myevent.keyCode==__){//edit -
// – was pressed
trace (“- is pressed”)};
}//end function detectKeypress
}//end if rowcount 1


This code is called for the first row, of course, there are similar loops for each of the 8 rows.

Final Year ProjectPermalink

Comments are closed.