dimanche 21 février 2016

Action Script 3- Assigning index to a reference variable or comparing two index numbers

I am writing a program in Action Script 3 to assign a name to a matching month using two arrays. I have it so it already checks to see if the name matches one in the array and likewise with the month array, but I am having trouble with the final if statement asking whether the index numbers of the two match.

var Name:Array = new Array("John", "Mike", "Ben", "Thomas", "Chuck", "Charlie", "Peter", "Robert", "Dick", "Tracey", "Brienne", "Tywin");
var Month:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var Wrong:String = new String("Sorry, Wrong Input");

stop();

startButton.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
// Start your custom code
var xName = NameInput.text;
var xMonth = MonthInput.text;
if (Name.indexOf(xName) != -1)
{
NameMatchOutput.text = xName;
}
else
{
NameMatchOutput.text = Wrong;
}

if (Month.indexOf(xMonth) != -1)
{
MonthMatchOutput.text = xMonth;
}
else
{
MonthMatchOutput.text = Wrong;
}
if (Name.indexOf(xName) = (Month.indexOf(xMonth)))
{
NameMonthMatchOutput.text = "They Match";
}
else
{
NameMonthMatchOutput.text = "They Don't Match.";
}

// This example code displays the words "Mouse clicked" in the Output panel.
trace("Mouse clicked");
// End your custom code
}   



trace(Name);
trace(Month);

Aucun commentaire:

Enregistrer un commentaire