开发者

Flex addEventListener - how to refresh the screen during called event?

I can't seem to find the answer to what I would开发者_StackOverflow 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


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜