PDA

View Full Version : Prevent replay after refresh or back button


sagacyte
07-19-2005, 04:32 PM
Hello.

I have this flash top banner that plays an animation for a normal html website.
Everytime the user goes to another page, or refreshes the site, the banner plays again.
This can get pretty annoying (some buttons are on the banner, too).

How can I prevent this?

Thank you very much.

Ruben
07-19-2005, 04:43 PM
Look into the local shared object (http://www.macromedia.com/support/flash/action_scripts/local_shared_object), it'll help you out with your problem...

:rolleyes: - Ruben

sagacyte
07-19-2005, 05:03 PM
Thanks for the tip, Ruben.
But will it pop a window asking the user to approve flash storing data in their machines every time? sounds freaky.

It looks like (I think) the SharedObject I need is the "Local" one.
I see some code there, but i'm not that good at code.

// Get the kookie
so = sharedobject.getlocal("kookie");

// Get the user of the kookie and go to the frame number saved for this user.

if (so.data.user != undefined) {
this.user = so.data.user;
this.gotoAndStop(so.data.frame);
}


What frame do I put that on?
And then...


// On each frame, call the rememberme function to save the frame number.
function rememberme() {
so.data.frame=this._currentFrame;
so.data.user="John";
}


Do I have to put that in EVERY FRAME? wicked.
Do I have to copy that code EXACTLY as it is?
Help appreciated...

Ruben
07-19-2005, 05:52 PM
No, this is what I was thinking of:
- At the beginning of the animation the movie checks if it has been played on that particular system before;
- If yes then don't play
- If no then do play

The script would look somewhat like this (of course you'll have to edit it slightly to fit into your movie):localSharedObject = sharedobject.getLocal("flashcookie" );
if (localSharedObject.data.beenHere){
stop();
}else{
play();
}
localSharedObject.data.beenHere = true;

:rolleyes: - Ruben

PS. Do note the the flashplayer-issue:Make sure Macromedia Flash Player 6 is installed. Refer to Version test for Macromedia Flash Player (http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_15507) (TechNote 15507).http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_15507

sagacyte
07-19-2005, 06:30 PM
That's a nifty piece of code...
Thanks again.

Okey... so i'm creating a flashcookie...
--> localSharedObject = sharedobject.getLocal("flashcookie" );

then i'm asking if the sharedobject "has been here" and does something.

--> if (localSharedObject.data.beenHere){
stop();
}else{
play();
}

Finally, it sets the sharedobject to "true", so when the movie plays at a future time, "been here" returns "yes".
--> localSharedObject.data.beenHere = true;

Is this correct?
I'm sorry to ask, but I wanna understand this, not just copy it (learning :D )

Finally, assuming I have a 2 frame preloader that (when full) goes to frame 3 (the movie itself)... what's the best frame to put this code in?
Thank you again.

Ruben
07-19-2005, 08:01 PM
I'm sorry to ask, but I wanna understand this, not just copy itOh nonono, I recogn it's really good to not just want to copy/paste it. Anyway, you're completely correct, if I were you I'd place the script on frame 3 and replace the stop() with a gotoAndStop which will display the last frame of the animation...

Good luck

:) - Ruben

sagacyte
07-19-2005, 08:23 PM
Thank you very much, Ruben!!
You've been really helpful.

See you around.
Nos vemos. :cool:

Ruben
07-19-2005, 09:44 PM
No problem

see you around at the boards

:cool: - Ruben

argento
12-13-2009, 03:08 AM
Hello

I've tryied this but no working for me...

this is on my first frame

localSharedObject = sharedobject.getLocal("flashcookie" );
if (localSharedObject.data.beenHere){
localSharedObject.data.beenHere = true;
gotoAndStop(3);
}else{
gotoAndStop(2);
}

second frame is stop button (music is playing)...

third frame is play button (music is off)


what I want to do .. is .. when I go to my page, music will start automatically,
and there is buton to stop it, but when he refresh the page or browsing subpages.. the music needs to be stopped...

please help .. thx