Hi, I'm having trouble with setting up a shared object and I really need some help from someone more enlighten then myself in the field of actionscript :)
Basically I have a talking character that introduces a site and says hello (basically an intro) but I don’t want him to repeat his speech every single time the area gets refreshed or the page gets revisited. On top of that I don’t want the speech to get skipped once and never seen again, I just want to reset the cycle a little later on.
The whole premise has become a little complex for me and I wasn’t really sure what the best way of doing this was, although through my travels I did find some code in a tutorial that implements a time control but I'm not exactly sure how to fix it up to apply to my situation.
This is put in the first frame to control the timing:
var today = new Date();
var so:SharedObject = SharedObject.getLocal("time");
var period = 15000;
Then this is put into the instance:
if (loaded == total)
{
if (!((_root.today-_root.so.data.val)<_root.period))
{
_root.so.data.val = _root.today;
_root.so.flush();
_root.gotoAndPlay(2); //full animation
}
else
{
_root.so.data.val = _root.today;
_root.par = "skip";
_root.gotoAndStop(162);
}
}
The issue is when I add it to the instance of course I get a:
**Error** Scene=Scene 1, layer=Speech Bubble, frame=1:Line 2: Statement must appear within on/onClipEvent handler
if (loaded == total)
because it hasn't been placed in a frame. Yet the tutorial seems to have no such problem.
I'm not sure if it can be placed in every frame but there’s 165 frames and many animations so an easier way to set up the code would be much appreciated.
I did consider setting up an 'enter page' however because of the nature of the situation and the character talking on every page and not just the main page (for example: he talks again in the ‘Links' page) I was concerned I would need a mechanism I can use throughout the site to prevent the problem as I can’t build an 'enter page' for every single link.
Otherwise I might just be going the complete wrong way about it and If there’s a method out there that makes more sense I would love to do it that way instead :) if you are able to help me thank you so much!