How do I save a dynamic text?
up vote
0
down vote
favorite
I have a dynamic text field that changes from 100 to 0 and vice versa when a button is clicked. I want this number to be saved when exiting the application, but it seems that it's not returning the last clicked value when the application reopens. This is the code, any help please?
import flash.events.MouseEvent;
import flash.media.SoundChannel;
import flash.ui.Mouse;
var saveDataObject:SharedObject;
var currentScore:Number;
options_mc.sound_btn.addEventListener(MouseEvent.CLICK, mute);
options_mc.test3.addEventListener(MouseEvent.CLICK, test3);
init();
function mute(event:MouseEvent)
{
if(currentScore == 100)
{
currentScore = 0
options_mc.onoff_txt.text = String(currentScore);
}
else if(currentScore == 0)
{
currentScore = 100
options_mc.onoff_txt.text = String(currentScore);
}
saveData();
}
function init():void
{
saveDataObject = SharedObject.getLocal("test");
currentScore = 100;
if (saveDataObject.data.savedScore == null)
{
trace("No saved data yet.");
saveDataObject.data.savedScore = currentScore;
}
else
{
trace("Save data found.");
loadData();
}
}
function saveData():void
{
saveDataObject.data.savedScore = currentScore;
trace("Data Saved!");
saveDataObject.flush();
trace(saveDataObject.size);
}
function loadData():void
{
if(currentScore == 100)
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
}
else if(currentScore == 0)
{
currentScore = saveDataObject.data.savedScore;
}
}
actionscript-3 flash
add a comment |
up vote
0
down vote
favorite
I have a dynamic text field that changes from 100 to 0 and vice versa when a button is clicked. I want this number to be saved when exiting the application, but it seems that it's not returning the last clicked value when the application reopens. This is the code, any help please?
import flash.events.MouseEvent;
import flash.media.SoundChannel;
import flash.ui.Mouse;
var saveDataObject:SharedObject;
var currentScore:Number;
options_mc.sound_btn.addEventListener(MouseEvent.CLICK, mute);
options_mc.test3.addEventListener(MouseEvent.CLICK, test3);
init();
function mute(event:MouseEvent)
{
if(currentScore == 100)
{
currentScore = 0
options_mc.onoff_txt.text = String(currentScore);
}
else if(currentScore == 0)
{
currentScore = 100
options_mc.onoff_txt.text = String(currentScore);
}
saveData();
}
function init():void
{
saveDataObject = SharedObject.getLocal("test");
currentScore = 100;
if (saveDataObject.data.savedScore == null)
{
trace("No saved data yet.");
saveDataObject.data.savedScore = currentScore;
}
else
{
trace("Save data found.");
loadData();
}
}
function saveData():void
{
saveDataObject.data.savedScore = currentScore;
trace("Data Saved!");
saveDataObject.flush();
trace(saveDataObject.size);
}
function loadData():void
{
if(currentScore == 100)
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
}
else if(currentScore == 0)
{
currentScore = saveDataObject.data.savedScore;
}
}
actionscript-3 flash
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a dynamic text field that changes from 100 to 0 and vice versa when a button is clicked. I want this number to be saved when exiting the application, but it seems that it's not returning the last clicked value when the application reopens. This is the code, any help please?
import flash.events.MouseEvent;
import flash.media.SoundChannel;
import flash.ui.Mouse;
var saveDataObject:SharedObject;
var currentScore:Number;
options_mc.sound_btn.addEventListener(MouseEvent.CLICK, mute);
options_mc.test3.addEventListener(MouseEvent.CLICK, test3);
init();
function mute(event:MouseEvent)
{
if(currentScore == 100)
{
currentScore = 0
options_mc.onoff_txt.text = String(currentScore);
}
else if(currentScore == 0)
{
currentScore = 100
options_mc.onoff_txt.text = String(currentScore);
}
saveData();
}
function init():void
{
saveDataObject = SharedObject.getLocal("test");
currentScore = 100;
if (saveDataObject.data.savedScore == null)
{
trace("No saved data yet.");
saveDataObject.data.savedScore = currentScore;
}
else
{
trace("Save data found.");
loadData();
}
}
function saveData():void
{
saveDataObject.data.savedScore = currentScore;
trace("Data Saved!");
saveDataObject.flush();
trace(saveDataObject.size);
}
function loadData():void
{
if(currentScore == 100)
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
}
else if(currentScore == 0)
{
currentScore = saveDataObject.data.savedScore;
}
}
actionscript-3 flash
I have a dynamic text field that changes from 100 to 0 and vice versa when a button is clicked. I want this number to be saved when exiting the application, but it seems that it's not returning the last clicked value when the application reopens. This is the code, any help please?
import flash.events.MouseEvent;
import flash.media.SoundChannel;
import flash.ui.Mouse;
var saveDataObject:SharedObject;
var currentScore:Number;
options_mc.sound_btn.addEventListener(MouseEvent.CLICK, mute);
options_mc.test3.addEventListener(MouseEvent.CLICK, test3);
init();
function mute(event:MouseEvent)
{
if(currentScore == 100)
{
currentScore = 0
options_mc.onoff_txt.text = String(currentScore);
}
else if(currentScore == 0)
{
currentScore = 100
options_mc.onoff_txt.text = String(currentScore);
}
saveData();
}
function init():void
{
saveDataObject = SharedObject.getLocal("test");
currentScore = 100;
if (saveDataObject.data.savedScore == null)
{
trace("No saved data yet.");
saveDataObject.data.savedScore = currentScore;
}
else
{
trace("Save data found.");
loadData();
}
}
function saveData():void
{
saveDataObject.data.savedScore = currentScore;
trace("Data Saved!");
saveDataObject.flush();
trace(saveDataObject.size);
}
function loadData():void
{
if(currentScore == 100)
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
}
else if(currentScore == 0)
{
currentScore = saveDataObject.data.savedScore;
}
}
actionscript-3 flash
actionscript-3 flash
asked Nov 16 '13 at 2:14
Sam
59110
59110
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
function loadData():void
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
if (options_mc.onoff_txt) options_mc.onoff_txt.text=String(currentScore);
}
Apparently you've missed the line that immediately writes the score to text field. You are seemingly doing the saving right.
Thank you so much!
– Sam
Nov 16 '13 at 4:16
add a comment |
up vote
0
down vote
As3
(Input.text)
(Dynamic.text)
(Button save)
If input text not blank
Saved //
If input text blank
Loaded //
If moving next frame
Dynamic text still exists //
If reopen app
Loaded
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
function loadData():void
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
if (options_mc.onoff_txt) options_mc.onoff_txt.text=String(currentScore);
}
Apparently you've missed the line that immediately writes the score to text field. You are seemingly doing the saving right.
Thank you so much!
– Sam
Nov 16 '13 at 4:16
add a comment |
up vote
0
down vote
accepted
function loadData():void
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
if (options_mc.onoff_txt) options_mc.onoff_txt.text=String(currentScore);
}
Apparently you've missed the line that immediately writes the score to text field. You are seemingly doing the saving right.
Thank you so much!
– Sam
Nov 16 '13 at 4:16
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
function loadData():void
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
if (options_mc.onoff_txt) options_mc.onoff_txt.text=String(currentScore);
}
Apparently you've missed the line that immediately writes the score to text field. You are seemingly doing the saving right.
function loadData():void
{
currentScore = saveDataObject.data.savedScore;
trace("Data Loaded!");
if (options_mc.onoff_txt) options_mc.onoff_txt.text=String(currentScore);
}
Apparently you've missed the line that immediately writes the score to text field. You are seemingly doing the saving right.
answered Nov 16 '13 at 4:11
Vesper
16.6k42749
16.6k42749
Thank you so much!
– Sam
Nov 16 '13 at 4:16
add a comment |
Thank you so much!
– Sam
Nov 16 '13 at 4:16
Thank you so much!
– Sam
Nov 16 '13 at 4:16
Thank you so much!
– Sam
Nov 16 '13 at 4:16
add a comment |
up vote
0
down vote
As3
(Input.text)
(Dynamic.text)
(Button save)
If input text not blank
Saved //
If input text blank
Loaded //
If moving next frame
Dynamic text still exists //
If reopen app
Loaded
add a comment |
up vote
0
down vote
As3
(Input.text)
(Dynamic.text)
(Button save)
If input text not blank
Saved //
If input text blank
Loaded //
If moving next frame
Dynamic text still exists //
If reopen app
Loaded
add a comment |
up vote
0
down vote
up vote
0
down vote
As3
(Input.text)
(Dynamic.text)
(Button save)
If input text not blank
Saved //
If input text blank
Loaded //
If moving next frame
Dynamic text still exists //
If reopen app
Loaded
As3
(Input.text)
(Dynamic.text)
(Button save)
If input text not blank
Saved //
If input text blank
Loaded //
If moving next frame
Dynamic text still exists //
If reopen app
Loaded
edited Nov 11 at 3:01
Stephen Rauch
27.3k153156
27.3k153156
answered Nov 11 at 2:33
Yusuf
1
1
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f20013833%2fhow-do-i-save-a-dynamic-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown