я хочу удалить указанный c элемент из массива - PullRequest
0 голосов
/ 08 апреля 2020

У меня есть 9 m c на стадии [a, b, c ..... i], и это itemIndex[] индекс содержания каждого m c, я хочу удалить указанную c элемент из itemIndex[], но проблема, которую я обнаруживаю, заключается в том, что, когда я нажимаю один и тот же m c, другие элементы продолжают удаляться из itemIndex [];

import fla sh. events.MouseEvent;

var myarray: Array = [a, b, c, d, e, f, g, h, i];
var itemIndex: Array = [];
for (var j: int = 0; j < myarray.length; j++) {
    myarray[j].addEventListener(MouseEvent.CLICK, goto);
    myarray[j].index = j;
    itemIndex.push(j);
}
function goto(e: MouseEvent): void {
    var r = e.target.index;
    itemIndex.splice(e.target.index, 1);// for exemple wen i click to this movieClip with the name a  
                                          //the index of a is 0 ; but 
    trace(itemIndex);
}
//output = 1,2,3,4,5,6,7,8
//         1,2,3,4,5,6,7 
//         1,2,3,4,5,6
//         1,2,3,4,5
//         1,2,3,4
//         1,2,3
//         1,2
//         1
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...