Flash Action Script Error Repository

A library of solutions to Actionscript, Flash, Flex and AIR

Archive for November, 2008

The compressed (zipped) folder is invalid or corrupt

Description
I exported a Flex Archive project to the desktop (Windows XP). When I tried to open it I received this message, “The compressed (zipped) folder is invalid or corrupt”.

Cause
Possibly a bug in Flex Builder export feature. Tested other projects and they would export fine. Only occured on certain projects. Might be related to using “${DOCUMENTS}” variable in the Flex Build Path. The ${DOCUMENTS} token is a variable that points to the current workspace.

Solution
But you can use Flex > Export > Other > General > Archive Project to export your project. All options can be left at default. To import the file you can continue to use Flex > Import > Flex Archive Project.
NOTE! You may have to recreate the “libs” folder if it is not there.

No comments

Error: Find criteria must contain at least one sort field value.

Error: Find criteria must contain at least one sort field value.

What it came down to is that the property was not on the object in the array collection. So the sortField(”my property”) didn’t exist on the object in my array collection. Actually, it did exist in my test data but what had happened was the array in my array collection was replaced with another array of items way before I thought it was. And these items didn’t have that property.

No comments

Cannot find when view is not sorted.

Cause
You are trying to create and use a cursor on an ArrayCollection but the sort property is null. Set a breakpoint in your code before the error and check yourArrayCollection.sort property (it will be null).


Problem

Actionscript:
  1. // create cursor to find item
  2. var cursor:IViewCursor = componentInstances.createCursor();
  3. var found:Boolean = cursor.findFirst(item); // error on this line



Solution

Actionscript:
  1. // define a sort on the array collection sort property
  2. // i am doing it on creationComplete in my init() function
  3. // but you can add when you need it
  4. private function init():void {
  5.     // Create the Sort instance.
  6.     var sort:Sort = new Sort();
  7.     // Set the sort field; we are using the default sort value here
  8.     sort.fields = [new SortField(null)];
  9.     // Assign the Sort object to the view.
  10.     componentInstances.sort = sort;
  11.     // Apply the sort to the collection.
  12.     componentInstances.refresh();
  13. }
  14.  
  15. // now this will work
  16. var cursor:IViewCursor = componentInstances.createCursor();
  17. var found:Boolean = cursor.findFirst(item); // study the findFirst method

1 comment