0

フレックスに問題があり、少し頭痛がします!

ArrayCollectionにオブジェクトを追加していますが、そうすることで、バインディングが発生していなくても、別のArrayCollectionもこれらの変更を取得しています。

デバッグから、2つのACのアドレスが同じであることがわかりますが、私の人生ではその理由を理解できません。

2つの配列コレクションがあります。

model.index.rows //The main array collection

model.index.holdRows //The array collection that imitates the above

このファントムデータバインディングは、ループの最初の反復でのみ発生し、他のすべての場合は1回だけ書き込みます。

これが厄介であることがわかっている理由は、データグリッドに重複したエントリが作成されるためです。

public override function handleMessage(message:IMessage):void
    {

        super.handleMessage(message);
        if (message is IndexResponse)
        {
           var response:IndexResponse = message as IndexResponse;

            model.index.rows.removeAll();
            model.index.indexIsEmpty = response.nullIndex;

            if (model.index.indexIsEmpty !== true)
            {

                //Update the index model from the response. Note: each property of the row object will be shown in the UI as a column in the grid
                response.index.forEach(function(entry:EntryData, i:int, a:Array):void
                    {
                        var row:Object = { fileID: entry.fileID, dadName: entry.dadName };

                        entry.tags.forEach(function(tag:Tag, i:int, a:Array):void
                            {
                                row[tag.name] = tag.value;
                            });

                        model.index.rows.addItem(row);

                    });

              if(model.index.indexForNetworkView == true){

                model.index.holdRows.source = model.index.holdRows.source.concat(model.index.rows.source);
                model.index.indexCounter++;
                model.index.indexForNetworkView = false;
                controller.indexController.showNetwork(model.index.indexCounter);                   
              }
                model.index.rows.refresh();
                controller.networkController.show();                  
            }

        }

似たようなものに遭遇した他の誰かが解決策を提案しますか?

4

2 に答える 2

0

私はこのstackoverflowスレッドで同じ質問をしましたが、何が起こっているのか、そしてそれを解決するために何ができるのかが説明されています:

ある変数への変更は別の変数に伝播します

ラディスラフ

于 2010-05-20T10:31:01.570 に答える
0

前述のスレッドを調べた後、私はこのように問題を解決しました:

私は次のような別のクラスでコードを設定しました:

model.index.rows = model.index.holdRows;

これはコード全体に伝播しているようです。代わりに、この行を次のように変更しました。

model.index.rows = new ArrayCollection(model.index.holdRows.source.concat());

言及されたスレッドで提案されているように。これにより、重複したエントリが削除されました。:o)

于 2010-05-20T10:51:20.523 に答える