I wanted to run a prompt to enter a name into a JS prompt on loading a scene and noticed different behaviour between browsers. Both Safari and Chrome show the prompt before anything on the page is visible, while Firefox shows the scene with the prompt in focus (see attached) BrowserOnSceneLoad.zip (18.2 KB)
.
I've got around the problem by running a timeline on scene load with a timeline action to run the JS prompt.
Is there another (better?) way I can achieve this with the scene showing before the prompt in each case, or is the best method?
The prompt is basically an Alert. So it does not surprise me you get the behaviour.
If the delay in the script being called works for you then yes that probably is ok.
I personally don't like alerts and prompts and feel that this is not the intended use for a prompt.
An alternative is to have the first scene act as your input area by using normal forms or as in this example contenteditable on a rectangle. Here I have added the attribute using Hypes built in Additional HTML attributes in the Identity inspector.
Perfect thank you. I've searched the forum for ages looking for a simple way to allow someone to enter their name without JS and obviously missed this simple setting. I like this much better, with or without the JS. Thanks heaps (again).
I've been trying to implement this on a single scene (as I've completed everything else in a single scene and haven't used more than 1 before) but I can't stop the dialog blocking interactivity in the objects behind it, even if moved off the screen by timeline.
Do you think it is possible to use this without jumping to another scene?
Thanks.
We then delete the details timeline on the main scene.
And remove the on scene load to start the details timeline.
We go into the symbol and on it's Main Timeline;
set the NameDialog group to hidden and opacity to 0 via the Element inspector.
When an element is hidden it will not intercept mouse/pointer events because it is hidden from the DOM ( and you ).
We then go the symbol's details timeline (create it if need be );
Turn on recording
Move the play head a couple of frames along and set the NameDialog group to visible via the Element inspector .
This can just be 2-3 frames after along as this property is either on or off and does not animate .
We still use opacity so we can get a nice fade in/out.
Still recording mover further along the timeline and set opacity to 100%.
Wow thanks for all that effort stepping me through that. I only dabble in Hype occasionally so its not hard to get myself confused. I didn't understand the symbols concept having the timeline within it, and also how to set objects to not be affected by pointer events.
I'm sure others will find your tutorial in this post valuable so I hope they can find it. I definitely
prefer this than JS prompts for alerts and prompts, especially if a page is embedded but hosted elsewhere, and the JS (at least in Firefox and Chrome) indicates to the user that the alert has a different domain than the page they are on, which could make them suspicious.
Thanks again, I'm sure I can implement this correctly now. Cheers.