Using Actionscript Worker to loop function to make it faster

爱⌒轻易说出口 提交于 2021-02-11 12:23:54

问题


My current code that allow application to upload data inside of Excel file into the AIR app is as follows;

import lib.xlsxreader.Worksheet;
import lib.xlsxreader.XLSXLoader;

public class Main extends MovieClip
{
    private var fileGet: File = new File();
    private var xloader: XLSXLoader = new XLSXLoader();

    public function Main()
    {
        fileGet = File.applicationDirectory;
        fileGet.addEventListener(Event.SELECT, selectExcel)
        xloader.addEventListener(Event.COMPLETE, uploadComplete);
        button.addEventListener(MouseEvent.CLICK, selectFile);
    }

    private function selectFile(e: MouseEvent): Void
    {
        fileGet.browseForOpen("Select File");
        xloader.load(fileGet.nativePath);
    }

    private function uploadComplete(e: Event): Void
    {
         ws = xloader.worksheet("[Name of the worksheet]");
         rowStart = 7;
         rowEnd = ws.rows;

         for (var i = rowStart; i <= rowEnd; i++)
         {
             //transferring data from excel into sqlite
         } 
    }
}

The code above is not my complete code, I just shorten it to the relevant code. Let me know if you need more information.

Right now the code is transferring data from 30 columns and 1000++ rows from Excel file for about 10 minutes which is kinda slow and make the AIR app appear 'hang' or 'frooze' during uploading.

It come to my attention that I can use Worker API in Actionscript to fasten this process but for the life of me, I can't exactly figuring out how to restructuring my code to allow Worker API in my code.

I have read through example from here, here and here, but I still can't make heads or tails on this issue.

As far as my understanding goes, my code //transferring data from excel into sqlite should be included in class CountResult from this example...?

Can someone help me on this problem. Take note that I'm a self-learn amateur programmer trying to learn to make dekstop app using Adobe Animate.

来源:https://stackoverflow.com/questions/61153868/using-actionscript-worker-to-loop-function-to-make-it-faster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!