Copy link to clipboard
Copied
Hello I Have script:
var gTeams:Array = new Array(teamName1,teamName2, teamName3);
var so:SharedObject=SharedObject.getLocal("dataSO");
var shared_data:String;
for (var i:int=0; i<gTeams.length; i++) {
if (so.data["team_name_" + i]) {
gTeams.text = so.data["team_name_" + i];
}
}
function saveTextF():void{
for(i=0;i<gTeams.length;i++){
so.data["team_name_"+i]=gTeams.text;
}
so.flush();
}
In other frames I have dynamic text fields:
tName1, tName2, tName3.
But I cant get text from input text fields.
How I can do that?
Thanks for your help
Use Event.CHANGE instead of TextEvent.TEXT_INPUT:
teamName1.addEventListener(Event.CHANGE, tName1F);
function tName1F(e:Event):void{
.
.
.
Note that the reply number 8 is the correct answer to your question.
Copy link to clipboard
Copied
save the text property of those textfields (after user entry) into a variable (or variables). you can then use those variable values when the input textfields no longer exist.
Copy link to clipboard
Copied
I get String cant be null or something like that.
Copy link to clipboard
Copied
Like this?:
var tName1 = teamName1.text;
var tName2 = teamName2.text;
var tName3 = teamName3.text;
tName1.text = tName1;
In dynamic text field I get: tekst "[object TextField]"
Copy link to clipboard
Copied
those variables can't be the same name as an object (like a textfield) and they need to be defined at the correct time: AFTER USER ENTRY. eg, use a textinput event listener/function and don't make those variables local to the listener function:
var teamName1_var:String;
teamName1.addEventListener(TextEvent.TEXT_INPUT,tName1F);
function tName1F(e:TextEvent):void{
teamName1_var=teamName1.text;
}
Copy link to clipboard
Copied
TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at as_fla::MainTimeline/frame3()
In third frame I have action:
tName1.text = teamName1_var
Copy link to clipboard
Copied
This works.
tName1.text = String(teamName1_var);
But I always have make changes in text field. If I run flash in Input text fiels already I have text from last time. But In dynamic text field I have "null"
Copy link to clipboard
Copied
Why in dynamic text field I lost my Last letter?
Copy link to clipboard
Copied
and make sure you embed your font.
Copy link to clipboard
Copied
I mean.
First time in text field I write: for example Johan Strauss
In other frame in dynamic field I see: Johan Straus //lost my last character
I close the flash;
Other time then I Open the flash in input text I already see Johan Strauss
If I want I can chane name but if I left Johan Strauss
In other frame dynamic field I see "Null"
Copy link to clipboard
Copied
FIRST frame with 3 text inputs:
stop();
var gTeams:Array = new Array(teamName1,teamName2, teamName3);
var so:SharedObject=SharedObject.getLocal("dataSO");
var teamName1_var:String;
var teamName2_var:String;
var teamName3_var:String;
for (var i:int=0; i<gTeams.length; i++) {
if (so.data["team_name_" + i]) {
gTeams.text = so.data["team_name_" + i];
this['teamName'+i+'_var'] = so.data["team_name_" + i];
}
}
teamName1.addEventListener(TextEvent.TEXT_INPUT,tName1F);
function tName1F(e:TextEvent):void{
teamName1_var = teamName1.text;
saveTextF()
}
teamName2.addEventListener(TextEvent.TEXT_INPUT,tName2F);
function tName2F(e:TextEvent):void{
teamName2_var = teamName2.text;
saveTextF()
}
teamName3.addEventListener(TextEvent.TEXT_INPUT,tName3F);
function tName3F(e:TextEvent):void{
teamName3_var = teamName3.text;
saveTextF()
}
function saveTextF():void{
for(i=0;i<gTeams.length;i++){
so.data["team_name_"+i]=gTeams.text;
}
so.flush();
}
SECOND frame with 3 Dynamic TextFields:
stop();
tName1.text = String(teamName1_var);
tName2.text = String(teamName2_var);
tName3.text = String(teamName3_var);
Copy link to clipboard
Copied
use your so to assign the variable values (when the so exists):
for (var i:int=0; i<gTeams.length; i++) {
if (so.data["team_name_" + i]) {
gTeams.text = so.data["team_name_" + i];
this['teamName'+i+'_var'] = so.data["team_name_" + i];
}
}
Copy link to clipboard
Copied
My fonts is embeded but in dynamictext fields I cant see last character and i dont understand why?
Copy link to clipboard
Copied
make sure your textfield is large enough to display all the characters. make sure your textfield is multiline if there's not enough room on one line and increase its height to display everything or scroll the textfield.
Copy link to clipboard
Copied
If I write "ONE" i see "ON". If i write one character see just empty field. If I write Johan Straus I see Johan Strau And why I cant understand... With all fiels in flash everything is ok with these nop.
Copy link to clipboard
Copied
use the trace function to make sure your variable values are correct.
if they are someone will probably need to download your fla to find the problem.
Copy link to clipboard
Copied
With trace I have the same
Copy link to clipboard
Copied
If someone can look my *.fla That would be greate.
Copy link to clipboard
Copied
Someone?
Copy link to clipboard
Copied
Use Event.CHANGE instead of TextEvent.TEXT_INPUT:
teamName1.addEventListener(Event.CHANGE, tName1F);
function tName1F(e:Event):void{
.
.
.
Note that the reply number 8 is the correct answer to your question.
Copy link to clipboard
Copied
Super duper Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now