0

The following code is used in a component I name FileUpload.mxml which is used in two three different sections of the flex application.

private var uploadURL:URLRequest = new URLRequest;
private var file:FileReference = new FileReference;
private var media:MediaFacade;

public function browse():void
{
        var uUrl:String=""; // force
        uploadURL=new URLRequest();

        file=new FileReference();
        configureListeners();

        file.browse(getTypes());
}

private function configureListeners():void
{
    file.addEventListener(Event.CANCEL, cancelHandler);
            ...
    if (!Application.application.hasEventListener("uploadFileEvent")) {
        Application.application.addEventListener("uploadFileEvent", uploadFile);
    }
}

When it is used in the first instanced, it works fine, but when it is used in different sections it gets the following error from the code below:

Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.

    private function doUploadFile():void
    {
        try
        {
            file.upload(uploadURL);
        }
        catch (e:Error) {
            trace(e.message);
        }
    }

It follows the same sequence every time, i.e., file=new FileReference; configureFileListeners(file); file.browse(); file.upload(uploadURL) but only works on the first instance of the component being created.

Any ideas would be appreciated.

Thanks in advance.

Angus.

4

2 に答える 2

1

私はFlexの初心者ですが、読んだことから:

.browse() の前に .cancel() を呼び出して、競合するイベントがないことを確認してください。

于 2013-12-31T16:54:20.070 に答える
1

browseCLICK イベントなどの「User-Interaction」イベントから直接呼び出すことができるメソッドのみです。関数またはクラスでラップすると、そのエラーが発生します。

于 2010-09-02T08:29:45.883 に答える