Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1958638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T08:23:09+00:00 2026-05-17T08:23:09+00:00

I have a recursive call which includes an asyn operation (file copy) .. I

  • 0

I have a recursive call which includes an asyn operation (file copy) ..
I want to find out when the recursive call finishes (along with all asyn operations).

    private function copyInto(directoryToCopy:File, locationCopyingTo:File):void
        {
          var directory:Array = directoryToCopy.getDirectoryListing();
          //get list of files in dir 

          for each (var f:File in directory)
          {
            if (f.isDirectory)
              copyInto(f, locationCopyingTo.resolvePath(f.name));
            else
             {
               f.copyToAsyn(locationCopyingTo.resolvePath(f.name), true);
               f.addEventListener(Event.COMPLETE, onFilecopied);
              }
          }    
        }

function onFileCopied(event){ 
    alert(event.target); // [object File] 
} 

Basically what I needed was to copy a folder structure to another drive,and the folder
being copied contains some files that are 100-200MB and which take time to copy,which
blanks out the UI and the flash player.
And after the files get copied, I want to do further things(hopefully without
blocking the UI).

Any help?

Thanks All .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T08:23:10+00:00Added an answer on May 17, 2026 at 8:23 am

    Count the calls of copyToAsync and use a wrapper function like doCopy in my example.

    private var copyCount: int = 0;
    private var isCopying: Boolean = false;
    
    public function doCopy(directoryToCopy:File, locationCopyingTo:File):void
    {
        isCopying = true;
        try {
          copyInto((directoryToCopy, locationCopyingTo);
        finally {
          isCopying = false;
        } 
    }
    
    private function copyInto(directoryToCopy:File, locationCopyingTo:File):void {
        var directory:Array = directoryToCopy.getDirectoryListing();
    
        for each (var f:File in directory) {
            if (f.isDirectory)
                copyInto(f, locationCopyingTo.resolvePath(f.name));
            else {
                copyCount++; 
                f.addEventListener(Event.COMPLETE, onFileCopied);
                f.copyToAsync(locationCopyingTo.resolvePath(f.name), true);
            }
        }    
    }
    
    function onFileCopied(event: Event): void
    { 
        copyCount--;
        if (copyCount == 0 && !isCopying)
            trace("finished");
    } 
    

    Important: The isCopying flag checks if the copyInto function is still running, otherwise you could run into to a condition where copyCount == 0, but the copying is not finished.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here's the situation: I have a recursive, asynchronous AJAX call which is pulling
I have a recursive table in which each record has an ID and a
I have this recursive method which deletes empty folders: private void DeleteEmpty(DirectoryInfo directory) {
I have a recursive method call. When any exception is thrown, I would like
I have a MVC application which has a Controller that has a recursive method
I have written a pair of methods in python: number_combinations() which obtains all possible
In the Fibonacci sequence, I have seen conventional implementations which recursively call the same
I have a recursive algorithm which steps through a string, character by character, and
I have a recursive function which can be written like: void func(TypeName *dataStructure, LL_Node
I have a function which aims to perform a recursive calculation. If my function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.