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

Using two textfield inputs to perform a function

Explorer ,
Apr 24, 2018 Apr 24, 2018

I would like to use two text field inputs to perform a function.

if text1.text = text2.text then gotoAndStop(2);

but its not working.

TOPICS
ActionScript
828
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

Community Expert , Apr 26, 2018 Apr 26, 2018

Hi.

It's been years since the last time I coded in AS2, but I think it may be what you want:

stop();

txt0.onKillFocus = function()

{

    changeFrame();

};

txt1.onKillFocus = function()

{

    changeFrame();

};

function changeFrame()

{

    if (txt0.text == txt1.text)

        gotoAndStop(2);

}

Notice that I chose to fire the comparison when one of the text fields loses focus. But you can fire the comparison using a click of a button, a loop, and so on.

Regards,

JC

Translate
Explorer ,
Apr 26, 2018 Apr 26, 2018

can someone help me please,

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 ,
Apr 26, 2018 Apr 26, 2018

Hi.

It's been years since the last time I coded in AS2, but I think it may be what you want:

stop();

txt0.onKillFocus = function()

{

    changeFrame();

};

txt1.onKillFocus = function()

{

    changeFrame();

};

function changeFrame()

{

    if (txt0.text == txt1.text)

        gotoAndStop(2);

}

Notice that I chose to fire the comparison when one of the text fields loses focus. But you can fire the comparison using a click of a button, a loop, and so on.

Regards,

JC

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 ,
Apr 26, 2018 Apr 26, 2018

thank you very much,

very helpful and correct.

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 ,
Apr 26, 2018 Apr 26, 2018

can you help me with something similar please too ?

if the two text fields have a button seperately from each other,  can you add a code to create the entered data into a text field input, that will keep creating new textfield underneath each other, and side by side, seperately, if its a long code i can do them seperately say a button called left and a button called right and a text input on the left caled text.left and a text input on the right called text.right.

and another text input field called search and its search button called search_btn,

can the search_btn together with the text entered into the text input search through the created textfields on both the left and right side?

please can help me with this code.? and what do you suggest if there is an match ? the above code to use? but perhaps slightly altered??

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 ,
Apr 26, 2018 Apr 26, 2018

Quickly going back to the code you helped me with, i tried to add a button to it and on preview got a blank preview, so

what can i write to but it on a button release called go6.

go6._visible = true;

go6.onRelease = function(){

......

?

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 ,
Apr 26, 2018 Apr 26, 2018

Hi! I'm glad it helped you!

Hmmm... I think I'm not getting what you want.

Would you mind explaining again? Sorry about this.

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 ,
Apr 26, 2018 Apr 26, 2018

sure okay,

i hadnt design frame(2) and got a blank page, the code you gave me worked, i went a drew a simple hello on frame (2) and because the text inputs were the same both being blank i had no control on the function and the code executed and went straight to frame (2), so i was asking if i could control it with a button, i took the code and added it to each text input seperately, and added the

  1. function changeFrame() 
  2. if (txt0.text == txt1.text) 
  3.         gotoAndStop(2); 
  4. }

to the button called go6, and still it did the same,

i tried go6.onRelease = function(){

function changeFrame()

{

if ttxt0.text == txt1.text)

gotoAndStop(2);

}

and it still just went and stoped at frame (2) without me having time to fill in the two textfields and pressing go.\

i also wanted to know this morning, the if part it has currently two text fields, could it be 4 text fields? if so how would i write in another set of two that need to match each other called txt3.text and text4.text with the

if (ttxt0.text == txt1.text)

gotoAndStop(2);

would it be

if (ttxt0.text == txt1.text);

if (txt3.text == txt4.text)

gotoAndStop(2);

those two questions ive got, and this most important, before asking to help me with :

i know i got 4 questions., the third question is : the code to add to the two buttons called go1 and go2 with txt0 and txt1,

so that once entered and the button is pressed that that a new textfield is created in a column like fashion, and next to the column the date entered in txt1 when go2 is pressed. not too big, 300 x 35, and in top left corner the first column,

and the forth question is a textinput called search and a search button called serach_btn that the text entered in the search looks in the left column only and a second one that looks in the right column text input called search_1 and ill use the same button search_btn.

dont know how you fel helping me with the four questions at once, or just the questions you can do, lets start with my first two questions if thats ok ?

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 ,
Apr 30, 2018 Apr 30, 2018

?

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 ,
Apr 30, 2018 Apr 30, 2018

Hi again.

Sorry for the delay.

And sorry again because I still don't get it...

Would you mind explaining briefly what you need? Like:

1 - I need a button to do this;

2 - I need a text field to display that;

3 - And so on...

Regards,

JC

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 ,
Apr 30, 2018 Apr 30, 2018
LATEST

i got a small quiz, and a few buttons, the quiz is in devolopment still and has been split into a left side and a right side, its all in the same movie clip and has many text input fields that work with some buttons.

on the left the "teacher" me, can right in a text input "instructions" and in another "question 1" and in another " 1+1" and press a button and it displays in the right side of the page "where the student would fill in the answer and read what i sent in the three text inputs, that went from my three text inputs to their three text inputs, ,

thankfully that part work great, the student fills in the answer in a text input field and presses a button and the answer is duplicated back to the "teachers " left side, that works great, the teachers side also has a text input for an "correct answer" that is not sent through to the student, and on the teachers left side of the page is another button that checks to see if the teachers answer = the students answer and delivers a answer to a text input that currently is giving "true" or false" thats cool,

i would like to do a function on the teachers answer and the students answer that gives a mark allocation instead of just a "true" or "false" that can appear next to the text input giving the "true" or "false" answer,

If the student.text and teacher.text are the two text fields, and a button called go_btn and a result text field called result.text;

i would like to use a mark allocation text input field for the questions mark called mark_allocation.text to be used to be displayed in the "result.text" if full marks are given if the students answer matches the teachers answer.

after the student has pressed his button to submit the answer i wanted the students graphics part which is a boonlean, to dissapear and a new question to appear or to go to another frame number and to be able to come back to the same frame to see the question, which i can do using the function to gotoAndStop or the function ._visible = false;

the code you helped me with, help to send the timeline to the specifiec timeline frame when two text inputs were identical, i might have left out a stop on frame 1 that led to to go straight to that frame number, that code was code on the keyframe and acted without a button press function and previously i wanted to know if that same code could be added to a button, lets call the button go_nextFrame_btn,

i would like to do the teachers mark allocation part first please, and then as an option to use the mark allocation as the two text inputs that would allow the students right side to go to the frame on the timeline thus not allowing the movement until the right answer/ answer is selected.

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