9 Replies Latest reply on Sep 2, 2008 8:53 AM by kglad

    Actionscript problem

    ahrens1977
      Ok, here is my code for the main movie clip,
      maxtry = 0;
      finalans =""
      result ="Passed"

      //-----Interventions-----------------//

      int1="None";
      int2a="Increase Oxygen";
      int2b="Decrease Oxygen";

      Here is the next coding part that is in 2 movie clips deeper (2 child) Sorry if I am not saying that right.

      answer_1_btn.onRelease = function() {
      // trace ("Max value is = " + maxtry );
      _parent._parent.maxtry = _parent._parent.maxtry + 1
      _parent._parent.result="failed"
      maxtrycount ();
      function maxtrycount () {
      _parent._parent.finalans = finalans + int2a;
      _parent._parent.result ="failed";
      if (_parent._parent.maxtry < 2 ) {
      // 1st attempt
      _parent._parent.gotoAndStop("home");
      }
      else {
      if (_parent._parent.maxtry == 2 )
      // second attempt //
      _parent._parent.result = "failed";
      _parent._parent.gotoAndStop("summary");
      }

      }

      And here is the coding for the final portion of this coding and is 2 movie clips deep on the main timeline:

      exit_case_btn.onRelease = function() {

      saveXML = new XML(_parent._parent.result+","+_parent._parent.finalans);
      saveXML.ignoreWhite = true;
      trace("========================================");
      trace("choices selected = "+_parent._parent.finalans);
      trace("_parent._parent.result value before sending data = "+_parent._parent.result);
      trace("========================================");
      System.security.allowDomain(" http://www.icu-usapro.com/gsb/");
      System.security.allowDomain(mypath);
      saved = new XML();
      saved.onLoad = confirm;
      saveXML.send(" http://www.icu-usapro.com/gsb/result.php",saved);
      trace("status of xml file = "+this.status);
      };


      The pass and fail portion of this coding works perfectly. But, I cannot view the finalans portion and it is coming up NaN. When I try to change the _parent._parent to _global, it then comes up undefined. I am at a loss for why this would not be working. Any suggestions?
        • 1. Re: Actionscript problem
          kglad Adobe Community Professional & MVP
          to display code in this forum you should copy and paste your code using the attach code option.

          as it is, your answer_1_btn onRelease has, at least, one syntax error. and saveXML doesn't look like it will be a well-formed xml object.

          further, there's nothing in your code where you're trying to use finalans as a number so the flash compiler wouldn't generate a NaN error for that string.
          • 2. Re: Actionscript problem
            ahrens1977 Level 1
            Sorry about that and thanks for the reply. I know that NaN should not show up, but that is my response in the Trace section. Also, when I check the syntax, I come up with no errors. Again, I am trying to get these answers to show and they are not. I am baffled because the coding looks fine to me.
            • 3. Re: Actionscript problem
              kglad Adobe Community Professional & MVP
              the coding doesn't look fine to me.
              • 4. Re: Actionscript problem
                ahrens1977 Level 1
                Oh, ok. I guess my reason for posting my question was because I thought something was wrong and was looking for some assistance. I would appreciate your help instead of just telling me it is not fine. Thank you.
                • 5. Re: Actionscript problem
                  kglad Adobe Community Professional & MVP
                  i already did. again:

                  your answer_1_btn onRelease has, at least, one syntax error

                  saveXML doesn't look like it will be a well-formed xml object.

                  i know you don't see a syntax error so the code you posted doesn't match the code in your fla. so, to display code in this forum you should copy and paste your code using the attach code option.
                  • 6. Re: Actionscript problem
                    ahrens1977 Level 1
                    Thanks for your help. Let me try this again.
                    Here is the exact coding again:

                    This first portion is 1 movie clip deep. The other 2 are 3 movie clips in.

                    This is straight from the fla file.

                    I am not seeing the syntax error on this. This is the coding that results in the NaN.

                    Also, could you explain more about the savexml not being a well formed object.
                    I appreciate your help. This coding was inherited from an Indian Company and we are trying to get it to work in a more complicated fla file while still interacting with our database in the same manner.
                    Thanks again.
                    • 7. Re: Actionscript problem
                      ahrens1977 Level 1
                      Another piece
                      • 8. Re: Actionscript problem
                        ahrens1977 Level 1
                        Final piece:

                        • 9. Re: Actionscript problem
                          kglad Adobe Community Professional & MVP
                          the compiler may not be giving you an error with your answer_1_btn.onRelease, but that's not good coding. even though flash will accept the lack of a left curly after an if-statement, that's not good coding.

                          next, use trace(saveXML) to see that you're not creating an xml structure.

                          and finally, your function maxtrycount() is referencing finalans which is going to be undefined because it lacks a path so when you try and load that to a string and then assign that to _parent._parent.finalans, you're going to get NaN.