Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS3 SharedObject From Input to dynamic text field in other frames..

Explorer ,
Jan 19, 2016 Jan 19, 2016

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

TOPICS
ActionScript
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Feb 15, 2016 Feb 15, 2016

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.

Translate
Community Expert ,
Jan 19, 2016 Jan 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

I get String cant be null or something like that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

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]"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2016 Jan 19, 2016

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

Why in dynamic text field I lost my Last letter?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2016 Jan 19, 2016

and make sure you embed your font.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2016 Jan 19, 2016

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];

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

My fonts is embeded but in dynamictext fields I cant see last character and i dont understand why?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2016 Jan 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2016 Jan 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

With trace I have the same

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

If someone can look my *.fla That would be greate.

Dropbox - textTEST.fla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 15, 2016 Feb 15, 2016

Someone?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 15, 2016 Feb 15, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2016 Feb 17, 2016
LATEST

Super duper Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines