7 Replies Latest reply on Sep 25, 2006 3:06 AM by coldMiner

    DateField selectedDate

    l810c
      If I build a small flash file with only this functionality, everything works. But I have a large app, loading another app with a form(movieclip) I'm loading.

      3 components on my screen.
      but_submit -Button
      txtDate - Textfield
      dfDate - DateField

      but_submit.onRelease = function() {
      trace("txtDate.text " + txtDate.text);
      trace("dfDate.selectedDate" + txtDate.text);
      }

      I enter 2006/09/24 in txtDate.
      Choose 2006/09/24 with DateField.
      Click but_submit
      Results:
      txtDate.text 2006/09/24
      dfDate.selectedDate undefined

      I put this code on the DateField control
      on (change) {
      trace("Change");
      trace(this.selectedDate);
      }

      When I change the date I get this:
      Change
      Mon Sep 25 00:00:00 GMT-0400 2006

      I don't get it, what am I missing?

      I used a dumproot function to dump all the objects on the moveclip and get this:
      this dfPO_Date -> _level0.mcStatusB.mcStatusB1.dfPO_Date
      this txtCustomer -> _level0.mcStatusB.mcStatusB1.txtCustomer
      this but_submit -> _level0.mcStatusB.mcStatusB1.but_submit



      For now I guess I'll just set all of the values to global variables. Gross!
        • 1. Re: DateField selectedDate
          coldMiner
          Not sure what you are asking, but maybe this helps:
          //
          but_submit.onRelease = function() {
          trace("txtDate.text: " +this._parent. txtDate.text);
          trace("dfDate.selectedDate: " +this._parent. txtDate.text);
          }
          • 2. Re: DateField selectedDate
            l810c Level 1
            The thing is I can't get the date from the datefield without some insane programming.

            txtDate.text 2006/09/24
            dfDate.selectedDate undefined - Why is this undefined??!!??

            I've simplified the code for demonstration, but I also have radio buttons, check boxes and text areas on this form(movieclip). They all behave like the text field. Only the DateField will not give me it's value from the scope of the form(movieclip). It will give me the value from it's own on (change) event.

            I've tried every iteration of this and this.parent, believe me, but the fact is this component is not acting like all of the other components. The dumproot also verifies the scope.
            • 3. Re: DateField selectedDate
              coldMiner Level 1
              lets do the spagetti:
              what about this then:
              on frame1 actions:
              var mySelectedDate:String;
              /////
              and on the datafield control:
              on (change) {
              _root.mySelectedDate = this.selectedDate;
              }
              //
              and on the button:
              but_submit.onRelease = function() {
              trace("dfDate.selectedDate " + _root.mySelectedDate);
              };
              //
              //
              but if the button is a component should you not use something like this:
              function clicked() {
              trace("You clicked the button!");
              }
              my_button.addEventListener("click", clicked);

              • 4. Re: DateField selectedDate
                l810c Level 1
                Thanks coldMiner,

                I have certainly created a Hack(have to do that often with Flash). I'm mainly looking for a more elegant solution or just a confirmation that this is just another BUG or By Design ;)
                • 5. Re: DateField selectedDate
                  coldMiner Level 1
                  ? Maybe this fla can clear things up for you:
                  http://www.coldminer.com/test/test.zip
                  • 6. Re: DateField selectedDate
                    l810c Level 1
                    coldMiner,
                    That is very close to what I am doing. It works.

                    This:
                    http://eastmetrotechnology.com/test/test3.zip

                    Is about exactly what I am doing. It works also.

                    But something is not working in my app and that's what driving me nuts. The DateField is not behaving like the rest of the components behave in this instance.

                    My app has grown Very large. It's over 10000 lines of code with ~60 ActionScript classes and 80+ swf's. It's sometimes very hard to track down problems.

                    Thanks for your help.
                    • 7. Re: DateField selectedDate
                      coldMiner Level 1
                      quote:

                      Originally posted by: l810c
                      My app has grown Very large. It's over 10000 lines of code with ~60 ActionScript classes and 80+ swf's. It's sometimes very hard to track down problems.


                      Not sure what your problem is...
                      ... but it sounds like your app is ready for OOP, more easy to track down errors.
                      Try keeping all your code central in seperate .as files.
                      Code in true AS2, example:
                      var myVar:String = "test";
                      function testFunc(theVar:Array):String{
                      return(theVar[0]);
                      }
                      var arrString:String = testFunc(myVar);
                      // yelds the error:
                      **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: Type mismatch.
                      var arrString:String = testFunc(myVar);

                      // if you do this in AS1 code:
                      var myVar = "test";
                      function testFunc(theVar){
                      return(theVar[0]);
                      }
                      var arrString = testFunc(myVar);
                      // you get no error, and you don't know what is wrong.
                      // and must search your code to find out why arrString is undefined