PDA

View Full Version : Shared Objects


Latte
06-15-2005, 11:56 PM
OK I have looked into this and I really cannot find specific enough intructions.

So here is my story and question:

I have a movie on several different pages of my site. So when you navigate through the site the same movie shows at the top of the page. What I would like to do is let the movie load if it needs to and play a small build out animation. Then using shared objects set a var that says loaded and save that to a shared object.

Once a user navigates to a different page with the same flash movie on it the page will call up the shared object and instead of playing the build animation it just goes to the last frame of the flash movie.


I just don't want to annoy the users of the site by making them see the same animation over and over again, and I know that with share objects this is possible, I just do not know how to write the AS.

I have searched for this but all I can find is how to do it with text boxes and buttons.


Any help would be awesome! I want to learn how to do this so just pointing me in the right direction would be great, unless you already have the code to do it. :)


Thanks in advance,

Latte/

Gibberish
06-16-2005, 05:23 AM
you looked a this? http://www.actionscript.org/tutorials/intermediate/SharedObjects/index.shtml

Latte
06-17-2005, 03:15 AM
Yeah I did not quite understand it the first time around. Thank you for that link! :)

I was able to find and mess with the following:


var mySO:SharedObject = SharedObject.getLocal("savedFrame");
var trackFrame:Number=_currentframe;
if (mySO.data.frameNum==undefined) {
mySO.data.frameNum=_currentframe;
mySO.flush();
trackFrame=_currentframe;
} else {
jumpToFrame=mySO.data.frameNum;
gotoAndPlay(jumpToFrame); //or gotoAndStop ... whichever you may need.
}

this.onEnterFrame=function() {
if (trackFrame<>_currentframe) {
mySO.data.frameNum=_currentframe;
mySO.flush();
trackFrame=_currentframe;
}
}




It works perfect for tracking the last frame that was viewed.

Now what I would like to do is clear my SO when the browser window has been closed.

mySO.clear() I think will delete it, but how do I do it when the window closes?

Thank fo any help.

Latte/

oldnewbie
06-17-2005, 05:40 AM
Why bother clearing it?

Latte
06-17-2005, 07:59 PM
Well the flash movie will be on every page and I don't want my users to see the same animation over and over everytime they navigate the site. I would however want them to see the animation next time they come back to the site.

SO Clearing it once the flash player closes (or browser closes) would do the trick.

Any ideas?


Tia,

Latte/

Gibberish
06-17-2005, 08:20 PM
i think this would require some javascript.

Through I am not sure you can control if they use the actual close button on the browser. I have only seen this type of feature in ad-ware.