michael
michael

Reputation: 1160

Flex return back the result after the event complete

I have two functions in an ActionScript class, they are:

private function loaderCompleteHandler(event:Event):void
{
        _loader = Loader(event.target.loader);
    selectedBitmap = Bitmap(_loader.content);
}

public function byteArrayToBitmap( byteArray:ByteArray ):void
{
    _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, loaderCompleteHandler );
    _loader.loadBytes( byteArray );
}

Is it possible to send the selectedBitmap variable back to the byteArrayToBitmap function after the event completed?

Upvotes: 0

Views: 1179

Answers (1)

Glenn
Glenn

Reputation: 5342

Not clear what you want to do.

You cannot return anything from the same call stack as the original call to byteArrayToBitmap, and there's no "sleep" available in AS3. Once you get into "loadCompleteHandler", you cannot return anything to the caller of byteArrayToBitmap. So you'll have to modify the caller to wait for the event COMPLETE and then check for the selectBitmap object. This will have to be stored somewhere.

That is, if I understand your problem.

Upvotes: 1

Related Questions