Im building a sample pad type instrument for a project, i have four channels for four different instruments the interface has four buttons to select the instrument, when the button is selected the image should be green but when another instrument is selected it should go to the second frame of the movie clip which is a red button to signal them instrument is off.
Line 23 i added a conditional statment for the variable associated with the channels it doesnt spit out any errors but also doesnt change the image when i click another button anyone know where im going wrong
//import flash stuff
import flash.events.MouseEvent;
import flash.display.MovieClip;
stop();
//event listener for the power button
poweroff.addEventListener(MouseEvent.CLICK, mouseClick1);
function mouseClick1(event:MouseEvent):void{
gotoAndStop(1);
}
//select which samples to use with event listener,
//changes var selector bellow, so input listens for
//different samples
drumSelector.addEventListener(MouseEvent.CLICK, drumClick);
function drumClick(event:MouseEvent):void{
selector = drums;
if (selector == drums)
{
drumSelector.gotoAndStop(1);
}else{
drumSelector.gotoAndStop(2);
}
}
bassSelector.addEventListener(MouseEvent.CLICK, bassClick);
function bassClick(event:MouseEvent):void{
selector = bass;
}
synthSelector.addEventListener(MouseEvent.CLICK, synthClick);
function synthClick(event:MouseEvent):void{
selector = synth;
}
beatSelector.addEventListener(MouseEvent.CLICK, beatClick);
function beatClick(event:MouseEvent):void{
selector = beat;
}
//selects which movieclip samples to use for input
var selector:MovieClip = drums;
//listen for events on display keyboard
//make movieclips visible so they can play samples
key1.addEventListener(MouseEvent.CLICK, key1Click);
function key1Click(evt:MouseEvent):void
{
selector.i1.visible=true;
}
key2.addEventListener(MouseEvent.CLICK, key2Click);
function key2Click(evt:MouseEvent):void
{
selector.i2.visible=true;
}
key3.addEventListener(MouseEvent.CLICK, key3Click);
function key3Click(evt:MouseEvent):void
{
selector.i3.visible=true;
}
key4.addEventListener(MouseEvent.CLICK, key4Click);
function key4Click(evt:MouseEvent):void
{
selector.i4.visible=true;
}
Create a new function for conditional like:
Then in each button handler: