Trouble with Array.contains()
-
in this function:
inline function getAllNoteObjectsInTie(staffIndex, barNumber, noteObject) { if (noteObject.type != "note" || !isTied(noteObject)) return; local objectIndex = findObjectIndexFromNOR(staffIndex, barNumber, noteObject); local startAddress = findTieChainStart(objectIndex); local intialNoteObject = scribeData[startAddress.staffIndex][startSddress.barNumber][startAddress.objectIndex]; local noteObjects = []; noteObjects.push(intialNoteObject); // push the first noteObject in tieChain local i = objectIndex +1; while (true) { local nextObj = findNextNoteObject(staffIndex, barNumber, i); noteObjects.push(nextObj); Console.print("nextObj: " + trace(nextObj)); if (nextObj.specialFlag.contains("tieEnd") || nextObj.type == undefined) return noteObjects; } }
Where the Console.print is clearly showing that
nextObject.specialFlag does indeed contain "tieEnd":
Interface: nextObj: { "noteObject": { "type": "note", "noteValue": "1/2", "x": "1/1", "y": [ "D#6" ], "noteNumber": [ 75 ], "direction": "down", "selected": [ 0 ], "specialFlag": [ null, "tieEnd" ], "attachments": { "stem": { "heightExtension": 0 } } }, "staffIndex": 0, "barNumber": 3, "objectIndex": 1 }
What might be causing the .contains not to work on an array?
-
specialFlag
is withinnoteObject
, no?@VirtualVirgin said in Trouble with Array.contains():
while (true)
If your if statement is ever
false
you'll be trapped in this loop. Should you be incrementingi
in this loop? -
@d-healey Right on both counts of course!!