×

Discussion Board

Results 1 to 7 of 7

Threaded View

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    3

    Shared Objects Problem (FL 2.1)

    I'm saving some values in the shared objects. Data are being saved and retrieved perfectly (i see the visual part of the app changes along with variable altering). After every change to any variable I use so.data.flush() to save it to the object instantly.

    Problem starts when i close my application (using the red phone symbol) and restart it. Variables are being reset to initial state.

    Should i use a designated "quit" button assigned to one of the softkeys? I would like to avoid that, since the users will definitely avoid that one too

    I just don't get where have i gone wrong in that one.

    Here's how i initialize SO:
    Code:
    //initiating shared objects:
    
    so = SharedObject.getLocal("variables");
    var now = new Date();
    if (so.data.so_check!=1){
    	so.data.Con = 5;
    	so.data.Str = 1;
    	so.data.Int = 1;
    	so.data.Fat = 0;
    	so.data.Hap = 0;
    	so.data.Rom = 0;
    	so.data.Hair = 2;
    	so.data.Money = 200;
    	so.data.timestamp = (now.getTime())/86400000;
    	//USE actions variables
    	so.data.useGym = 0;
    	so.data.useHealth = 0;
    	so.data.useRead = 0;
    	so.data.useJunk = 0;
    	so.data.useSex = 0;
    	
    	//married?
    	so.data.married = false;
    	
    	so.data.so_check = 1;
    	so.data.flush();
    }	
    
    
    //init handler - assigns variables form shared object to global variables
    soInitHandler = function(so:SharedObject){
    	if (so.getSize() > 0){
    		//all the variables get here
    		Con = so.data.Con;
    		Str = so.data.Str;
    		Int = so.data.Int;
    		timestamp = so.data.timestamp;
    		money = so.data.money;
    		//Use acations variables
    		useGym = so.data.useGym;
    		useHealth = so.data.useHealth;
    		useRead = so.data.useRead;
    		useJunk = so.data.useJunk;
    		so.data.so_check = 1;
    		
    		
    	}
    	
    }
    
    SharedObject.addListener("variables" , soInitHandler);
    And a sample save to SO:
    Code:
    //sample save to shared object function:
    function goToGym(){
    	//Altering basic attributes
    	
    		so.data.Str = so.data.Str + 0.1;
    		so.data.Con = so.data.Con + 0.1;
    		so.data.Int = so.data.Int - 0.1;
    		so.data.money = so.data.money - 20 ;
    	
    	//Reseting the Use vars for other actions
    	so.data.useHealth = 0;
    	so.data.useRead = 0;
    	so.data.useJunk = 0;
    	
    	
    	
    	so.data.useGym = so.data.useGym + 1;
    	
    	
    	
    	so.data.flush();
    	Key.removeListener(_root.myListener);
    	gotoAndStop(2); 
    }
    Just checked the app on Sony Ericsson (which runs flash lite 1.1) and it saved the SO. Now i'm dazzled. Is it just Nokias that don't allow to save data on the phone?!?
    Last edited by Kloucek; 2008-06-05 at 10:53. Reason: Edit:

Similar Threads

  1. Active Objects & Incoming Call Problem
    By jguzman in forum Symbian
    Replies: 5
    Last Post: 2007-03-21, 22:01
  2. Active Objects problem!!
    By harish13_ks in forum Symbian
    Replies: 14
    Last Post: 2006-12-27, 07:28
  3. nds 2.1. - problem with Series60_MIDP_SDK_2_0_for_SymbianOS
    By kidcandy in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2004-06-19, 17:34
  4. NDS 2.1 HTTP Connection Problem
    By pkc2k in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2004-06-12, 16:53
  5. Problem may be due to the COM objects???
    By alisqi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-09-19, 01:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •