A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: SharedObject issue

  1. #1
    Junior Member
    Join Date
    Dec 2016
    Posts
    1

    SharedObject issue

    Hi there folks,

    I'm having a small issue with the implementation of SharedObject.

    My code is:

    Code:
    var my_so:SharedObject;
    
    function jumpIn(){
    	attachMovie("startScreen", "startScreen", _root.getNextHighestDepth(),{_x:0,_y:24});
    	if(my_so.data.player != undefined){
    		trace(my_so.data.player);
    		startScreen.myName.text = my_so.data.player;
    	}
    	else{
    		my_so = SharedObject.getLocal("dataGatherer"); // defines the SharedObject
    	}
    }
    
    jumpIn();
    and then later on in a dynamicMC

    Code:
    startScreen.dataEntry.onRelease = function() {  // button is being pressed here
    	numQ = startScreen.myQ.text;
    	//count=numQ;
    	me = startScreen.myName.text;
    	myMail = startScreen.myEmail.text;
    	if (startScreen.myName.text == "" || startScreen.myQ.text == "" || startScreen.myEmail.text == "") {
    		display.htmlText = "Please enter your name, your email address and the number of questions you wish to answer.";
    	} else if (numQ<1) {
    		display.htmlText = "You must select between 1 and 50 questions";
    	} else {
    		my_so.data.player = startScreen.myName.text;
    		timer = numQ*90;// total time available in seconds
    		initial_time = timer;
    		startClock();
    		display.htmlText = "Click the question button to continue "+me;
    		startScreen._visible = false;
    		qbtn.enabled = true;
    		reset_btn.enabled = false;
    		for (var k = 0; k<topics.length; k++) {
    			var tarray = topics[k].slice(2, 3);
    			loadArray(myQuestions[tarray]);// load up the array
    		}
    		randomiseArray();
    	}
    };
    The idea being that a repeat visitor will have his details filled into the dynamicMC form field rather than having to do it him/her self.

    It's not working.

    Any idea where I'm going wrong?

    Regards,

    Charco

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    It would be much easier for you to attach your *.fla, save having to try and mimic your file.
    Then we can try to help you out a little more.

  3. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Hi this is my shared object:


    var high_score=10;
    var saveData:SharedObject;
    function startup(){
    saveData = SharedObject.getLocal("sol_fn");
    high_score = 0;
    if(saveData.data.scoreSaved == null){
    }else{
    loadData();
    }
    }

    function save_Data(){
    saveData.data.scoreSaved = high_score;
    saveData.flush();
    }

    function loadData(){
    high_score = saveData.data.scoreSaved;
    trace("hi score is " + saveData.data.scoreSaved);
    }

    startup();

    just call save_Data(); and the var high_score will be saved to the sol file


    call loadData(); and the variable high_score will be the last thing you used save_data(); on
    Last edited by AS3.0; 12-12-2016 at 08:50 PM.

  4. #4
    Member
    Join Date
    Oct 2016
    Posts
    54
    maybe he share code and we make fits togetyher

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center