mardi 29 septembre 2015

Delay user input for file.save() in as3?

So, the way flash works is that it requires user input in the same frame that a file.save() is called, otherwise it throws an error.

Problem

I'm using alivePDF to render out a PDF of some things on screen. It takes a few seconds to render everything, so the user is left looking at the same screen without being able to click anything, then the save dialogue pops up. I want to throw up a loading screen, just so the user is aware of what's happening. However, it wont render on screen while the PDF is being created, since the frame hasn't ended yet, so the loading screen appears just as the save dialogue is promped, so they're left looking at the same screen still.

My Temporary Solution

What I ended up doing was waiting for the PDF to load before prompting the save dialogue. However, as I said before, flash will throw an error without user input on that frame. So, I added a "save" button that prompts the dialogue. This is less than ideal, because then it's like 3 clicks to save a PDF and it's just less than desirable. Click the savePDF button, wait, click the save button again, then click the save dialogue's save button. See my issue?

Is there a way to delay the user input by 1 or 2 frames so flash will let me call the save() dialogue automatically? Or maybe force a render call mid-frame to show the loading screen while the PDF is getting ready, so that the user input, the loading screen, and the save() dialogue are called in the same frame, but the render is called at the onset of the PDF loading?

Aucun commentaire:

Enregistrer un commentaire