# Shard objects

**URL:** <https://forum.kirupa.com/t/shard-objects/22965>\
**Category:** Uncategorized\
**Created:** [June 11, 2003, 5:17am UTC](https://forum.kirupa.com/t/shard-objects/22965 "2003-06-11T05:17:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xpeder](https://avatars.discourse-cdn.com/v4/letter/x/22d042/32.png) [@Xpeder](https://forum.kirupa.com/u/Xpeder)\
**Post date:** [June 11, 2003, 5:17am UTC](https://forum.kirupa.com/t/shard-objects/22965/1 "2003-06-11T05:17:49Z")

</div>

I know there is a tut on shard objects but i was wondering if there is a way to like have a score and then have it save so every time you come back it is the same and keeps going up. for example there is a button and you click it and it says one then you refresh the browser and then it still says one so over time it will be like over 1,000:chinaman:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 11, 2003, 5:51am UTC](https://forum.kirupa.com/t/shard-objects/22965/2 "2003-06-11T05:51:59Z")

</div>

thats pretty well covered in the tutorial

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 12, 2003, 4:03am UTC](https://forum.kirupa.com/t/shard-objects/22965/3 "2003-06-12T04:03:26Z")

</div>

i am not to good with actionscripts so can you kinda break it down for me? thanx

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 13, 2003, 9:16pm UTC](https://forum.kirupa.com/t/shard-objects/22965/4 "2003-06-13T21:16:12Z")

</div>

function onLoad(){  
mySO=SharedObject.getLocal(“hitcounter”);  
if(mySO.data.hits==null)  
mySO.data.hits=0;  
mySO.data.hits++;  
mySO.flush();  
\_root.hitcount=mySO.data.hits;  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 13, 2003, 9:19pm UTC](https://forum.kirupa.com/t/shard-objects/22965/5 "2003-06-13T21:19:27Z")

</div>

translation (line by line)

when the movie loads  
create or find a previous cookie called “hitcounter”  
if the hits variable has never been set  
set it to zero  
then add one to it (whether it is new or not)  
update the cookie file  
set the \_root.hitcount variable to be the current hitcount from the cookie (now just make a text field that has \_root.hitcount as its variable)
