Hi there, I have a little problem with an animation in my web site, this animation have a little bell sound whe starts, My problem is that I want that soun to play only one time when people visit the website and stop to play in the meanwhile the people visit the other sections.
this is the code I haved been using:
intro_sound = new Sound ();
intro_sound.attachSound("my_sound");
var played_so = SharedObject.getLocal("played");
if (played_so.data.played)
{
intro_sound.stop();
} else {
intro_sound.start(0, 1);
}
intro_sound.flush();
I’am a newbie with actionscript so please help me with this
oh, I see I made a mistake, it shouldnt be intro_sound.flush, but played_so.flush, sorry
Now for the question you asked via pm,
I dont know a way to delete the shared object by “leaving” youre page…
What i once did was put the date into the SO, and compared that with the date it is…so it plays only once a day.
Maybe you can use that, but if someone else knows a way to delete SO on leaving, than Im curious too on how to do that
I need some more info about the way you have youre site build.
Is that thing were talking about a header or smth simular ?
And that header is included on different html pages ?
If yes, than i think i have a solution, you can change the SO on the index page via flashVars (so this will only work if people enters on the index page (not if they bookmarked smth else and enter there)(and even that is possible if you work with js history i guess)but its better than nothing, cuzz most people will enter the index.
If you use different pages with this swf header, all you have to do is put a flashVar on the index that will change the SO
for example this in the index.html
<param name=FlashVars VALUE="&played=no">
And in the onload function you pass that value to the SO
On the “other” pages you dont put this flashVar
So if you enter the index, it will play, if you enter “sub” pages it wont…
I think it would be more easy if you have php, this way you can use sessions, sessions are gone if browser is closed, so 2X more “luck”
I can make a verry long story out of this, but basicly I dont think there is an “onClose” thingy, and to make my idea work i need more info, and it wont be a solution for everyone, but only for youre site structure.
hopefully you understand what i say beqausse my english sucks as well
**bigFat edit: **if you have php, you can check on the $_SERVER[‘HTTP_REFERER’] and than change the flashVar…that would be easy
not that i understand anything from that language, but i think the thingy on the left side of the logo in the header plays the sound ?
And youre working with a <?php include(“blaat.php”) ?> sytem…hmmm
Now its late her, but tomorrow im gonna look at it, i think its possible to fix it like i said, now im of to my bottle of whiskey
Cya 2morrow here (or not) ill post my experiences here. gn8
Hmmzz, Im not having any luck…I can make flash detect if it have to play or not as you can see here
But…for some strange reason (I dont know why) It doenst work if I want to fix it in the onLoad = function(){}
It works with an onEnterFrame function…but than te sound KEEPS playing
So if anyone knows why it doenst work in the onLoad…pls tell
onEnterFrame = function () {
if (info != "yes") {
//intro_sound = new Sound();
//intro_sound.attachSound("my_sound");
//intro_sound.start();
test.text = "youve NOT seen this page before, so I have to play a sound";
} else {
test.text = "yes youre browsing on my site, so I DONT have to play a sound";
}
};
Ive commented out the sound stuff, beqausse it keeps playing, but in an onLoad it doesnt work (for me), maybe I did something weird.
Anyway, if you can manage to do this in an onload, than you dont need SO at all.
Sorry about my delay to answer, but yesterday was Monday and I had to go to work :beard: Thank’s for all your help and I hope we can find and answer to this problem