Reteras Remus
Reteras Remus

Reputation: 933

Play sound and image

At the moment I'm developing a very simple page like "scary maze". I have 2 same images with tiny edits in photoshop. The person must find 3 differences to jump to the next level. The trick is when he finds the differences it displays a scary image with a sound.

I want to build up the page with HTML, JS and PHP. I know all similar pages are made with flash, but since I have no any experience in it I can't develop with it.

I know there is a load time (when sound or image bits are stored in computer memory) and I need to find a way to display everything all the same time with no load. It must pop up instantly with the sound effect.

Actually (with this experience) I think I need to use CSS rule to hide the scary image with absolute position, and check with JS if it has been loaded ( <img src="" onload="g_imgLoaded++" /> ). Is this a good way to store the image bits in memory then to pop-up the image? What about the sound effect? How am I supposed to load it?

Upvotes: 1

Views: 185

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324600

Yes, that would work. Similarly, you can have the <audio> element on the page with preload="auto" to ensure the sound will be loaded when it it needed. Nothing ruins an attempted scare more than lag.

Upvotes: 4

Related Questions