0

I can't seem to find the answer to what I would have thought was a common problem.

What I want to do this is: 1. Show the Open File Dialog 2. Process the file selected 3. During processing the file, report progress to the User

I have a file defined, and am using the browseForOpen and AddEventListener:

public var fileInput:File = new File();
fileInput.browseForOpen("Open file",[filter]); 
fileInput.addEventListener(Event.SELECT, onFileSelect);

// Step 2 - function gets called to process the file
private function onFileSelect(e:Event):void
{
    // Step 3 - do some processing, and at intervals report progress to the screen
}

My issue is - any changes to the screen within the event listener do not get done until the function is complete.

Any help would be appreciated, Thanks

Neal Hudson
  • 231
  • 1
  • 5
  • 17
  • 1
    Maybe your processing goes to quickly? The Flex screen will only redraw based on it's frame rate and I believe the default is 24 frames per second. So, if your file processing takes less than 1/24th of a second; that is why the processing is done before your visual updates display. Otherwise you should share some code behind the event listener that updates the screen & processes the file. – JeffryHouser Sep 12 '11 at 20:49
  • No the processing takes a minute, thanks – Neal Hudson Sep 13 '11 at 12:27
  • Then you should consider sharing some code w/ details on how you're updating the screen; as that is most likely where the problem lies. You may also want to share some of the processing code. – JeffryHouser Sep 13 '11 at 14:29

2 Answers2

0

Start a timer perhaps and let it check status of a variable(that denotes processing progress) as a separate running function it would not be predisposed to waiting on the parent function.

[ to be clear Im saying call a sperate function from the timer.]

But I am inclined to agree with Flextras.com in that most times I have done this the processing was milliseconds so just didnt get seen.

Craig Mc
  • 505
  • 1
  • 13
  • 30
0

In Step 3, if you are doing some cpu intensive job(like huge xml parsing), then you might be seeing this NOT updating problem. As Flex is single threaded, you better make use of Green threading concept.

You can read about Green Threading here.

Community
  • 1
  • 1
M.D.
  • 1,886
  • 1
  • 13
  • 14