Posted By

blainejoubert on 02/06/09


Tagged

flash as3 SharedObject


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

allnatural
damarev
tspitzr


Flash AS3 SharedObject


 / Published in: ActionScript 3
 

  1. package
  2. {
  3. import flash.display.Sprite;
  4. import flash.net.SharedObject;
  5. import flash.text.TextField;
  6. import flash.text.TextFieldAutoSize;
  7. import flash.text.TextFormat;
  8.  
  9. import flash.utils.*;
  10.  
  11. public class SharedObjectReader extends Sprite
  12. {
  13. //the only one shared object we will work with
  14. private var _sharedObj:SharedObject;
  15.  
  16. public function SharedObjectReader ()
  17. {
  18.  
  19.  
  20. //open local shared object
  21. try
  22. {
  23. _sharedObj = SharedObject.getLocal("myID");
  24.  
  25. }
  26. catch (error:Error)
  27. {
  28. trace("SharedObject Error:"+error.toString());
  29. return;
  30. }
  31.  
  32. //read the values, if user had already been here, he has them already.
  33. trace("my ID " + _sharedObj.data.myID)
  34.  
  35.  
  36. //store the values
  37. _sharedObj.data.myID = 60;
  38.  
  39. //saving the values
  40. _sharedObj.flush();
  41.  
  42. //The call of close
  43. _sharedObj.close();
  44.  
  45.  
  46.  
  47. }
  48.  
  49. }
  50. }

Report this snippet  

You need to login to post a comment.