[JSFL] Remove textfields from stage

I’m looking for a way to remove all textfiends that is directly placed to the stage.
I do manage to get an array of the textfields, and I can get x, y, text etc. from it,
but no way I’ve tested so far has worked to target the field and remove it.

This is the code I got at the moment, I’ve tried thousands of ways to make it delete the fields, but the fields persists…


var textFieldArray = fl.findObjectInDocByType("text", doc);
for (var i=0; i < textFieldArray.length; i++){
    doc.selection[0] = textFieldArray*;
    doc.deleteSelection();
}

Output:

The function deleteSelection() is currently unavailable.

(This means the selection is empty)

I would really appreciate any help or tips given!

Thanks in advance,
Tompa