7 Replies Latest reply on Oct 28, 2008 9:36 PM by FlashTapper

    Problems with keyword activity

    FlashTapper Level 1
      Hi everyone! Just wondering if anyone has a simple answer to my problem, because I don't. I am developing a cloze/keyword question activity in flash where the user types a certain 'keyword' into a text box and then clicks on a button to validate if they have typed in the correct word. First of all I set up a string on the first line of code that executes when the user clicks on the submit button. Then the next line executes a function to convert what they have typed in the box into another string variable and then compare it to the stored variable within a simple if/else statement.

      I have run some trace commands to attempt to debug the script but they all indicate that it should be working. The code is attached to this post.

      Any assistance to this would be very helpful as I have googled the heck out of it and all I can find is dodgy software which generates these cheesy flash activities for a price i would not pay when i should be able to code it myself.
        • 1. Re: Problems with keyword activity
          kglad Adobe Community Professional & MVP
          if your trace output is "incorrect" followed by "contract", check the length of text1 to see if your getting whitespace in textField1's text property.
          • 2. Re: Problems with keyword activity
            Rothrock Level 5
            Well two things. If all your tests indicate it is working then what isn't working? You haven't told us.

            And two you are using an old style of coding that went out when Flash 6 was introduced in 2001.

            Instead of putting the press function (which would be more functional, in my opinion, if it were on release, anyways.) directly on the button put it on a frame. See an excellent blog on the issue:

            http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent

            Also in this type of testing remember to ask yourself are you teaching them them to type or do you want them to learn the word. So some folks might just type CONTACT and in some cases that is the same thing and in other not, but Flash will never see "CONTACT" == "contact"
            • 3. Re: Problems with keyword activity
              FlashTapper Level 1
              Thanks for your prompt reply. I did limit the characters to "9" in the property panel but it has not fixed the problem :(
              I know my coding style was way depricated but i was lazy - don't think it would have made much of a difference anyhow...i will go back and do it like "mybutton.onRelease = function(){" - it may make a difference.

              The activity is cloze or keyword where the learner has to type in the correct missing word. And you are right Rothrock - I did not think about a user typing in caps...I will have to set up a 'catch' for that, any suggestions? I know i used a piece of code in flash once to convert a textfield to lowercase (think it was inbuilt property of flash).

              Oh yeah and the reason why i know it doesn't work...the movie still traces 'incorrect' even when it has traced what is in the textfield and it matches up to the pre-stored variable, letter for letter - it should be tracing 'correct'.

              Thanks for your time and knowledge.
              • 4. Re: Problems with keyword activity
                Rothrock Level 5
                Don't take it personal. Today is just the day I decided to start crusading to get people off the Flash 5 syntax! :)

                Anyways, kglad is correct. You should check to see if there are some invisible characters in there that are part of the problem. I like to trace like this:

                trace("["+text1+"]")

                Which helps, but also checking the length property would be good.

                As for the other bit, there are two methods which could help toUpperCase() and toLowerCase() so you could probably use either to make sure the comparison is on equal footing so to speak.
                • 5. Re: Problems with keyword activity
                  FlashTapper Level 1
                  Thanks for that Rothrock...i was not taking it personally, just tried to justify myself for my sloppy coding ;) - i should know better (although i am so ill prepared for AS3!!)
                  Tried your suggestion but I still can't fix the problem :s

                  Attached is the revised script and beneath is what I get in the output window. I am a bit perturbed, usually i can do this stuff standing on my head with one hand.
                  • 6. Re: Problems with keyword activity
                    Rothrock Level 5
                    Yup. The problem is that somehow at the end of you textField you are getting an invisible line/carriage return of some sort. Not sure exactly how it is getting there.

                    If I make my input text field a single line type (assuming the textfield is placed in the authoring environment) I don't seem able to (at least easily) get a return in that field. But if I make it the multiline type I can get a return in there if I press the return/enter key or if I left it in there from when I created the text field.

                    Perhaps the easiest way to get rid of it is to set the text property of the field to nothing when you initialize your code.

                    textAnser1.text=""

                    Before the user has a chance to type in the field will make sure there isn't a secret invisible return -- or more than one.

                    A combination of single line and setting the property is probably the best bet.
                    • 7. Re: Problems with keyword activity
                      FlashTapper Level 1
                      Thanks very much mate! Champion. It was the fact it was a multi-line textfield...something i would have had trouble noticing...although i did find it unusual that the output window was putting in carrage returns in the traces it spat out..i just could not put my finger on it. I'm not sure how the extra character got in there either, i suspect its a quirk of Flash. As for setting the property of the text field to nothing when initialized - didn't need to, just made the text box single line and everything was sweet!

                      Thanks so much again - you just saved me heaps of time.