Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pausing ActionScript execution

Status
Not open for further replies.

alan6895

Programmer
Aug 3, 2007
48
US
I've scoured the internet to find a way to pause the execution of ActionScript in a Flash movie. I've found two main ways, but they both have serious problems for my needs. First, the setInterval function is no good for me because I don't need to call a function every so often. Second, the getTimer function inside a while loop eats up all of my processor and then makes IE say that the script is running slowly (go figure).

So, my question is, does anyone know of a simple, non-resource-intensive way to pause my ActionScript? I'm using a Flash-based file upload control to post files to an ASP .NET HTTPHandler, which saves them and processes them. The problem is that the way the ActionScript works now, it uses a for loop to go through the list of select files and send all of them to the handler individually, but successively. So when I get to uplaoding like 50 files with the Flash movie, it sends 50 different file stream to my server in about 2 seconds.

As you can imagine, this destroys my server in disk, processor, and network. I want to be able to pause between the start of each file upload request for 5-10 seconds, which will give the previous file a chance to either finish uploading or get very close to being done, thereby taking the load off the server. Any thoughts (from those of you who read this far)? Thanks!
 
Sounds like Interval is what you want but you said you don't want it - why?

Another approach is to wait for the server responce before moving onto the next file upload. I'd do it like this.

Kenneth Kawamoto
 
Hello Kenneth.
With setInterval, I couldn't get the Flash to work properly. That may have been something on my part as I'm brand new to ActionScript and am using code from CodeProject. Your second suggestion is actually exactly what I'd like to do. With the delay, my goal was to set it long enough so that the file would either finish uploading or be nearly done. How can I make it wait for a server response? I can post the AS here if you'd like. Any help you can give me is greatly appreciated. Thanks!
 
Alright, I'll give that a try. It does use the .upload() command, so I'll see what I can do. Thanks!
 
Kenneth,
I looked for info on the parameters of the Upload() command, but it only accepts the URL and might return a Boolean if there's a problem. However, it doesn't listen to the events from what I can tell. Does the fileref listener do this? I'm not sure where to go next. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top