This content has been marked as final. Show 6 replies
SharedObject is used to create data that will persist for a user even if they close the session and come back. In other words, that would be useful if you wanted the Sound to play on the first time the user *ever* visited your website, but never again even if they leave your site and come back a week later. Sounds like you just want it to play once 'per session', correct?
Try checking to see if the Sound has not been created yet, only if that's true then play the Sound. Like this:
b = new Sound();
you could place the code in a function that runs when the page is loaded.
Then within an movieClip.onLoadComplete fuction you could stop the Sound.. Or stop the sound while loading the next page.
Actually thats what i had in mind to only play once and never again. Your idea of playing once per session is a close second but the code didnt work . The whole home page isnt flash its just apart of the top banner does that make a difference?
Are you calling the sound from the html page or are you loading it in the flash banner ad?
> The whole home page isnt flash its just apart of the top banner does that make a
Ah, that's a big difference. This means the Flash session is closed when you change pages, so it's not any help. Yes, SharedObject would be a perfect solution for this.
> Are you calling the sound from the html page or are you loading it in the flash
> banner ad?
Refer to the first post, he's using the Sound object in Flash.
windsor, try this:
var so = SharedObject.getLocal("myIntro");
b = new Sound();
so.data.hasPlayed = true; //this data will be written when the user closes the Flash session
This doesn't seem to affect you in this case, but one thing to note about the SharedObject is that even if you explicitly flush() the data( so.data.flush() ), which writes the data immediantly to the user's machine, it won't be re-readable by any other Flash on the page untill it reloads.
In other words, it's not possible to communicate between SWFs on a page with a SO, you must use LocalConnection to do that, or force the page to refresh.