Guest User

Untitled

a guest
Aug 9th, 2011
750
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package {
  2. import flash.events.*;
  3. import flash.display.*;
  4. import flash.net.*;
  5. import flash.external.*;
  6.  
  7. public class Cram extends Sprite {
  8.  
  9. private var _so:sharedobject = null;
  10. private var _flushEnabled:boolean = false;
  11.  
  12. public function Cram(){
  13. super();
  14. try {
  15. _so = sharedobject.getlocal("cramjs");
  16. _flushEnabled = true;
  17. _so.addEventListener(NetStatusEvent.NET_STATUS, handleNetStatus);
  18. } catch(e:error) {
  19. _so = null;
  20. };
  21. if (((ExternalInterface.available) && (_so))){
  22. ExternalInterface.addCallback("get", soGet);
  23. ExternalInterface.addCallback("set", soSet);
  24. ExternalInterface.addCallback("remove", soRemove);
  25. };
  26. }
  27. private function soRemove(_arg1:string):void{
  28. delete _so.data[_arg1];
  29. flush();
  30. }
  31. private function flush():void{
  32. if (!_flushEnabled){
  33. return;
  34. };
  35. try {
  36. if (SharedObjectFlushStatus.FLUSHED != _so.flush()){
  37. _flushEnabled = false;
  38. };
  39. } catch(e:error) {
  40. _flushEnabled = false;
  41. };
  42. }
  43. private function handleNetStatus(_arg1:NetStatusEvent):void{
  44. if (_arg1.info.level == "error"){
  45. _flushEnabled = false;
  46. };
  47. }
  48. private function soGet(_arg1:string):string{
  49. var _local2:object = _so.data[_arg1];
  50. if (_local2){
  51. return (_local2.tostring());
  52. };
  53. return (null);
  54. }
  55. private function soSet(_arg1:string, _arg2:string):void{
  56. _so.data[_arg1] = _arg2;
  57. flush();
  58. }
  59.  
  60. }
  61. }//package
RAW Paste Data