A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Strange Dropping of Records

  1. #1
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813

    Unhappy Strange Dropping of Records

    I have a function that is suppose to simply loop through an array of objects. It checks each object to see if a variable is true, and if so, copies that object into another variable to be displayed. This is fairly simply and I've done it before, but this time each time it loops through the array, when it reaches an object that meets the criteria it will copy it, the next time it reach a matching record, it drops it from the array and moves forward. In total, it capture every other object that matches the criteria and removes the other. I am at a lost as to why this is doing it. I don't have a splice, pop, or any call to remove anything from any array. Here is my function below.

    Code:
    private function showOnlyPresentUnits():void
    {
    	model.iconPagesStorage = model.iconPages;
    
    	var pgGroup:VGroup = createPage();
    	model.iconPages = [];
    
    	for(var pgIndex:int = 0; pgIndex < model.iconPagesStorage.length; pgIndex++)
    	{
    		for(var iconIndex:int = 0; iconIndex < model.iconPagesStorage[pgIndex].numElements; iconIndex++)
    		{
    			var unit:UnitObj = model.iconPagesStorage[pgIndex].getElementAt(iconIndex) as UnitObj;
    			
    			if(unit.unitPresentSelected)
    			{
    				if(pgGroup.numElements >= maxIconPerPage)
    				{
    					model.iconPages.push(pgGroup);
    					pgGroup = createPage();
    				}
    				
    				pgGroup.addElements(unit);
    			}
    		}
    	}
    
    	if(pgGroup.numElements > 0)
    		model.iconPages.push(pgGroup);	
    
    
    	//Some other unmportant command, but the damage has been done before this point.
    }
    Can you take a look at the function above and let me know if some glaring issue I overlooked makes sense for every other selected object to be removed from the list entirely.
    Last edited by samac1068; 09-18-2013 at 08:37 AM. Reason: Correct some misspelling
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center