# Actionscript for shared object doesn't work in seperate .as class

**URL:** <https://forum.kirupa.com/t/actionscript-for-shared-object-doesnt-work-in-seperate-as-class/295358>\
**Category:** flash\
**Created:** [August 28, 2009, 4:32pm UTC](https://forum.kirupa.com/t/actionscript-for-shared-object-doesnt-work-in-seperate-as-class/295358 "2009-08-28T16:32:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tedri\_Mark](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@Tedri\_Mark](https://forum.kirupa.com/u/Tedri_Mark)\
**Post date:** [August 28, 2009, 4:32pm UTC](https://forum.kirupa.com/t/actionscript-for-shared-object-doesnt-work-in-seperate-as-class/295358/1 "2009-08-28T16:32:00Z")

</div>

Hi there, bit of an odd problem, I have the following piece of code

```auto

var myCookie:SharedObject = SharedObject.getLocal("mySavedData","/")
if(myCookie.data.mySavedText != undefined)
{
var gallerypath:String = myCookie.data.mySavedText;
}

```

which retrieves a shared data.

If I put this actionscript on the first frame of a new document, it works fine, however I want to use it in something I already have, which uses an external Document class.

Initially it failed to work as I had not included

```auto
 import flash.net.SharedObject;

```

at the beginning, which gave me a few errors like:

> 1046: Type was not found or was not a compile-time constant: SharedObject.

so I figured that out but now I get

> 1120: Access of undefined property myCookie.

I am puzzled as to why this should be, as it is clearly defined there, and also why this should not work in a separate document class when it works fine if it is in the actions window of the main project…

Any ideas\>?;(
