Skip to main content
Known Participant
February 7, 2015
Question

Sharing SharedObjects between Classes

  • February 7, 2015
  • 1 reply
  • 233 views

I have created a varable of Shared Object inside the Document Class

     EXAMPLE -> var so:SharedObject = SharedObject.getLocal("Barns","/");

but inside of a movieclip class I have

     if(so.data.adams == "yes"){

          adamsHighlight.visble = true}

and I get an error

E:\Android 2.0\ohioMap.as, Line 121120: Access of undefined property so.

what am i missing here. I thought if it was public, it is shared throughout the project

sorry new to classes.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 7, 2015

it is but so is not defined in your movieclip class unless you use:

var so:SharedObject=SharedObject.getLocal("Barns","/");

now, the so in your document class and in your movieclip class reference the same object.  eg,

//doc class

so.data.testvar="hi";

//movieclip class

trace(so.data.testvar);  // should trace 'hi'