开发者

Trouble with ArrayCollection in flex

开发者 https://www.devze.com 2023-04-09 05:37 出处:网络
I have trouble with ArrayCollection in Flex. He开发者_高级运维re is my code: private var productPageArr:ArrayCollection;

I have trouble with ArrayCollection in Flex. He开发者_高级运维re is my code:

 private var productPageArr:ArrayCollection;
 private var productCount:Number = 10;

 private function dviceProductPage(arr1:ArrayCollection,arr2:ArrayCollection):ArrayCollection       
 {      
    var page:Number = arr1.length      //productCount; 
    var i:int;
    arr2 = new ArrayCollection();

    //productPageArr = new ArrayCollection();

    for(i = 0; i<page; i++)
    {
      var o:Object = new Object();
      o.label = String(i+1);
      arr2.addItem(o);  
    }

    //arr2.refresh();
    return arr2;
 }

When I run this block of code, my application is terminated. But when productPageArr is replaced with arr2 then my application runs smoothly.


The problem is around the use of "arr2". "arr2" is an argument to your function, which may not be accessible from here.

I can't really tell what you are trying to achieve but my suggestion is to create a new variable within your function which you can safely return as the result of your function (which leaves the question as to why you are accepting "arr2" as an argument at all).

I hope this helps.

 private var productPageArr:ArrayCollection;
 private var productCount:Number = 10;

 private function dviceProductPage(arr1:ArrayCollection,arr2:ArrayCollection):ArrayCollection       
 {      
    var page:Number = arr1.length      //productCount; 
    var i:int;
    var arr3 = new ArrayCollection();

    for(i = 0; i<page; i++)
    {
      var o:Object = new Object();
      o.label = String(i+1);
      arr3.addItem(o);  
    }

    return arr3;
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消