×

Discussion Board

Results 1 to 7 of 7
  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:

  2. #2
    Product Specialist
    Join Date
    Jun 2003
    Location
    UK
    Posts
    191

    Re: Shared Objects Problem (FL 2.1)

    Which device are you targeting?
    Mark Doherty
    Developer Evangelist
    Adobe Systems, Mobile and Devices EMEA

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2006
    Location
    Mumbai, India
    Posts
    48

    Re: Shared Objects Problem (FL 2.1)

    If you are "flushing" the object using so.flush();, there is no reason why the SharedObject will not save the data. I think if you'll replace so.data.flush(); with so.flush(); in your code the Shared Object might work.

    You can refer to this article on persistent data saving - http://www.adobe.com/devnet/devices/...tent_data.html

    Also FL 1.1 does not support Shared Objects.

    Mariam
    Mariam Dholkawala
    http://www.igamestudio.com

    Blog - http://www.mariamdholkawala.com/mobile
    MaD UG - http://www.indimadgroup.com

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

    Re: Shared Objects Problem (FL 2.1)

    Thanks. As usual Devil lies in the details. Works like charm

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    7

    Re: Shared Objects Problem (FL 2.1)

    Quote Originally Posted by Kloucek View Post
    Thanks. As usual Devil lies in the details. Works like charm
    I say god is in the details,
    the Devil is in the minuter details
    thanks, it really helped me as well

  6. #6
    Registered User
    Join Date
    Oct 2009
    Posts
    1

    Re: Shared Objects Problem (FL 2.1)

    I have a diferent kind of problem with shared objects. My problem is more computer related. I'm developing some applications with Flash lite 2.1 using Macromedia Flash 8. Shared objects are working just fine, but as a result of many test I did,(I guess) now when I start app in Flash 8 (testing it on my PC) I get message:
    This movie is trying to save data and there is no spaca available. Would you like to delete the latest recently used storage taken by Flash movies?
    So I click OK, to confirm that I want to delete recently used storage, but next time I start (test) my app same thig happens again, and so on, and so on...
    Is there any way to delete all shared objects completely, and not just recent SOs, since that didn't solve my problem.
    And this shared objects, created by Flash lite emulator in Flash8 are not the same kond of shared objects created by regular flash player, or at least they are not located at the same place. I know where regular shared objects are located, and I deleted them manualy but that is not solution.
    Same message appears again when I test my app, even though I deleted shared objects.

    Does anybody know how to delete ALL shared objects created ba phone emulator?
    Last edited by miloshke; 2010-02-14 at 21:12.

  7. #7
    Registered User
    Join Date
    Dec 2008
    Posts
    46

    Re: Shared Objects Problem (FL 2.1)

    FlashTrayTools maybe ...?

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
  •