Skip navigation
jerm8352
Currently Being Moderated

Help on equation solving app!

Jun 21, 2012 3:57 PM

I am trying to make an app to help my students solve simple equations.  I want them to be able to input the necessary parts of an equation then be able to touch a button to reveal what each of the next steps would look like.  The design is terrible right now, I'm trying to get it functioning then worry about how it looks later.  It was moving along nicely but now I have hit a snag.  It works perfectly through the first step.  However, once I add the stuff to the performsecondstep function, I can't enter text into the text boxes at the begginning anymore.  I'm not sure of the problem.  I will post the code from when it works and then when it won't let me input text anymore.

 

Works fine,

 

import flash.text.TextFieldType;

 

onestepbtn.addEventListener(MouseEvent.CLICK, setonestep);

twostepbtn.addEventListener(MouseEvent.CLICK, settwostep);

firststepbtn.addEventListener(MouseEvent.CLICK, performfirststep);

var operator:String = new String;

var constant1:int = new int;

var answer:int = new int;

operator11.visible = false;

constantused1.visible = false;

constantused2.visible = false;

secondstepbtn.visible = false;

operator12.visible = false;

answeroutput.visible = false;

var constantinputtext:String = new String;

var answerinputtext:String = new String;

var operatorinputtext:String = new String;

operatorinput.restrict = "+\\-";

 

function setonestep(e:MouseEvent):void {

   

}

 

function settwostep(e:MouseEvent):void {

   

}

 

function performfirststep(e:MouseEvent):void {

    constantinputtext = constantinput.text;

    answerinputtext = answerinput.text;

    operatorinputtext = operatorinput.text;

    operator11.visible = true;

    operator12.visible = true;

    constantused1.visible = true;

    constantused2.visible = true;

    secondstepbtn.visible = true;

   

    if (operatorinput.text == "+") {

        operator11.text = "-";

        operator12.text = "-";

    } else {

        operator11.text = "+";

        operator12.text = "+";

    }

   

   

    constant1 = int(constantinputtext);

    answer = int(answerinputtext);

    constantused1.text = constantinputtext;

    constantused2.text = constantinputtext;

    firststepbtn.removeEventListener(MouseEvent.CLICK, performfirststep);

    operatorinput.type = TextFieldType.DYNAMIC;

    constantinput.type = TextFieldType.DYNAMIC;

    answerinput.type = TextFieldType.DYNAMIC;

    secondstepbtn.addEventListener(MouseEvent.CLICK, performsecondstep);

}

 

function performsecondstep(e:MouseEvent):void {

    answeroutput.visible = true;

    answeroutput.text = "hello";

}

 

This has dummy code for performsecondstep function.  When I actually put stuff in the function, I lose the ability to input text at the beginning of the program.  Not sure as to why.

 

import flash.text.TextFieldType;

 

onestepbtn.addEventListener(MouseEvent.CLICK, setonestep);

twostepbtn.addEventListener(MouseEvent.CLICK, settwostep);

firststepbtn.addEventListener(MouseEvent.CLICK, performfirststep);

var operator:String = new String;

var constant1:int = new int;

var answer:int = new int;

operator11.visible = false;

constantused1.visible = false;

constantused2.visible = false;

secondstepbtn.visible = false;

operator12.visible = false;

answeroutput.visible = false;

step2x.visible = false;

step2equals.visible = false;

var constantinputtext:String = new String;

var answerinputtext:String = new String;

var operatorinputtext:String = new String;

var isPlus:Boolean = new Boolean;

isPlus = true;

operatorinput.restrict = "+\\-";

 

function setonestep(e:MouseEvent):void {

   

}

 

function settwostep(e:MouseEvent):void {

   

}

 

function performfirststep(e:MouseEvent):void {

    constantinputtext = constantinput.text;

    answerinputtext = answerinput.text;

    operatorinputtext = operatorinput.text;

    operator11.visible = true;

    operator12.visible = true;

    constantused1.visible = true;

    constantused2.visible = true;

    secondstepbtn.visible = true;

   

    if (operatorinput.text == "+") {

        operator11.text = "-";

        operator12.text = "-";

    } else {

        operator11.text = "+";

        operator12.text = "+";

        isPlus = false;

    }

   

   

    constant1 = int(constantinputtext);

    answer = int(answerinputtext);

    constantused1.text = constantinputtext;

    constantused2.text = constantinputtext;

    firststepbtn.removeEventListener(MouseEvent.CLICK, performfirststep);

    operatorinput.type = TextFieldType.DYNAMIC;

    constantinput.type = TextFieldType.DYNAMIC;

    answerinput.type = TextFieldType.DYNAMIC;

    secondstepbtn.addEventListener(MouseEvent.CLICK, performsecondstep);

}

 

function performsecondstep(e:MouseEvent):void {

    answeroutput.visible = true;

    if (isPlus ==true) {

        answeroutput.text = String(answer - constant1);

    } else {

        answeroutput.text = String(answer + constant1);

    }

   

}

 

 

Any help would be much appreciated.

 

Thank you,

 

Jeremy

 
Replies
  • Currently Being Moderated
    Jun 21, 2012 4:03 PM   in reply to jerm8352

    If you are not showing the code that ends up causing a problem, there is not much anyone can do to help.  Are you familiar with using the trace() function to track down problems with code?  Do you get any error messages when you find the program failing?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 4:53 AM   in reply to jerm8352

    It wasn't clear which you were indicating has "dummy code".  I cannot see anything in the second set of code for that function that should cause any issue with matters that occur before trying to use that function. 

     

    If you are finding that adding that code is the only thing you change that causes it to go from working to not working, then you should try adding one line of code to it at a time until you see it fails.  For a function that is not being called before the failure occurs, I would expect some kind of error to be generated for that function if it is the cause.

     

     

    Just some minor details

     

    - you can instantiate and assign in one line, and you do not need to instantiate in some cases where you do, just for example...

     

         var operatorinputtext:String;  // if it has no value to assign, there is no need to

         var isPlus:Boolean = true;     // no need for two lines

     

     

      

     

    - you do not need to include the "== true" when you are testing a boolean value (or anything that can be differentiate as existing or not existing)

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 4:35 PM   in reply to jerm8352

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points