Skip to content
Discussion options

You must be logged in to vote

The important detail is that your image/sound branches are not returning the loaded asset yet. Both OpenFL APIs you are using are asynchronous:

BitmapData.loadFromFile(path):Future<BitmapData>
Sound.loadFromFile(path):Future<Sound>

So result is a Future, not a BitmapData or Sound. Trying to make that synchronous with:

while (!completed) Sys.sleep(...)

is the fragile part. On some targets the completion callback is dispatched through the current thread/event loop, and your sleep loop can prevent the callback from being processed. On HTML5 this is especially the wrong shape, because file/media loading is inherently async.

I would change the function to be async all the way through, for exam…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Minamotion
Comment options

Answer selected by Minamotion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants