shared object newbie
i have a movieclip that play on my webpage, i need to make when i refresh a page a movieclip start whenever frame it last were,
i know i have to use shared object but dont know how
is there any exsample of that? or someone can explain me how to do it?
thx
What version of Flash / AS are you using?
im using as2 but i can use as3 if is necessary, it is a simple slideshow with 4 images
Code:
var shared;
function check_position() {
shared = SharedObject.getLocal("savegame");
if (shared.data.current == undefined) {
shared.data.current = 1;
}
shared.close();
return shared.data.current;
}
function set_position(framenum) {
shared = SharedObject.getLocal("savegame");
shared.data.current = framenum;
shared.close();
}
trace(check_position());
set_position(3);
trace(check_position());
where i have to add this code?
Flash/Flex Developer
You can place the function anywhere, but if you want all movieclips to see it, you should place it on the main timeline.
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
i have tryed to add that cone on my timeline but it wont work, i have upload my movie clip if someone can take a look and tell me what im doing wrong...
thx
Attached Files
main timeline fraime 1
Code:
var shared;
function check_position() {
shared = SharedObject.getLocal("savegame");
if (shared.data.current == undefined) {
shared.data.current = 1;
}
shared.close();
return shared.data.current;
}
function set_position(framenum) {
shared = SharedObject.getLocal("savegame");
shared.data.current = framenum;
shared.close();
}
var lastframe = check_position();
trace(lastframe);
gotoAndPlay(lastframe);
main timeline frames 50, 100, 150, 200
Code:
set_position(_currentframe);
Last edited by dawsonk; 05-25-2010 at 09:59 AM .
that script work perfect, but my movieclip have 2000 frames and i have to put set_position(_currentframe); on each one,
is there another way to do the same thing?
Code:
var shared;
function check_position() {
shared = SharedObject.getLocal("savegame");
if (shared.data.current == undefined) {
shared.data.current = 1;
}
shared.close();
return shared.data.current;
}
function set_position(framenum) {
shared = SharedObject.getLocal("savegame");
shared.data.current = framenum;
shared.close();
}
this.onEnterFrame = function() {
set_position(_currentframe);
};
var lastframe = check_position();
trace(lastframe);
gotoAndPlay(lastframe);
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width