7 Replies Latest reply on Apr 8, 2008 3:24 AM by SteveH59

    'No Show' in dynamic text box

    SteveH59 Level 1
      Hello

      I am trying to show the following simple counter script in a dynamic text box (MX 2004).

      For my AS (2) I have:

      myVars = new LoadVars();
      myVars.load("hitCount.asp");
      myVars.onLoad = function(success){
      if(success){
      counter.text = this.counter
      } else trace ("Error")
      }

      The dynamic text box I am using to display the hit numeral has a purple font, an instance name of counter, and in the var field of my MX 2004 file I have intHits.

      My ASP script shows: response.write "counter=" & intHits

      and everything works fine.

      Then I decided I did not only want the numeral to show - meaningless in itself - but the word 'visitors' alongside it. So, I have now scripted the ASP as follows:

      response.write "counter=" & intHits & " <span style=""color:#cdcdcd"">visitors</span>"

      When I click on this file in my server I get what I was aiming for, namely:

      counter=22 visitors (with the word 'visitors' in grey).

      But when I check my movie, all the dynamic box shows is the word 'undefined'.

      Can anyone help, please?

      Thanks.

      Steve
        • 1. Re: 'No Show' in dynamic text box
          robdillon Most Valuable Participant
          It might be simple. Did you change the onLoad function to read: "counter.htmlText = this.counter"? Did you set the textField to use html?
          • 2. Re: 'No Show' in dynamic text box
            SteveH59 Level 1
            Hello Rob

            Many thanks for your post. I have used the following as you suggested:

            myVars = new LoadVars();
            myVars.load("hitCount.asp");
            myVars.onLoad = function(success){
            if(success){
            counter.htmlText = this.counter
            } else trace ("Error")
            }

            but still get 'undefined' in my dynamic text box. Then I pressed the <> symbol (I think that is the Render as HTML symbol, isn't it?) and uploaded the file again, but still get 'undefined' in there.

            I wonder if I need to set the html property of the TextField object to true? If so, how would I go about that, please, or do you think the problem is deeper than that now?

            Thanks for your time.

            Steve
            • 3. Re: 'No Show' in dynamic text box
              robdillon Most Valuable Participant
              If you have set the textfield on your stage and selected the <> button in the properties window for that textfield, then it is set to use html text. When you load text into an dynamic textfield you have to specify that the content type will be htmlText, and you've done that.

              I'm guessing that you've embedded a font, and that hasn't changed since you had a successful display.

              You can test the efficacy of the html text by loading in some local text:

              counter.htmlText = "<b> howdy </b>"

              when you run that, you should only see howdy in the textfield.

              There are only a limited number of legal html entities that you can use in a flash textfield. They are listed in the online help.
              • 4. Re: 'No Show' in dynamic text box
                robdillon Most Valuable Participant
                Also, did you trace the result from the server to see if Flash is receiving the string correctly?
                • 5. Re: 'No Show' in dynamic text box
                  SteveH59 Level 1
                  Hello Rob

                  Thanks again for your post.

                  When I use

                  counter.htmlText = "<b> howdy </b>"

                  This is exactly what I see: howdy

                  (with HTML rendered as you originally suggest. That is, I see no <b> tags)

                  Does this mean that the AS is correct?

                  I am just wondering about my original:

                  counter.text = this.counter

                  and your:

                  counter.htmlText = this.counter

                  In both cases this.counter does not refer to already written text (such as your 'howdy'). Rather, it is the instance name of my dynamic text box.

                  Or is counter.text/counter.htmlText = this.counter trying to reference the word 'counter' used in my ASP script?

                  Yes, the font used in my FLA file to show the numeral is an embedded FLA purple font and I was hoping to use
                  the word 'visitors' alongside it in a grey font (which I show, not in my FLA file as with the numeral, but in the ASP
                  script).

                  You mention tracing the result from the server. I am not sure about how to trace (I have no access here to Firefox if that is what you mean). On the server, the ASP file itself shows counter=22 visitors (with the word 'visitors' in grey).

                  What is a bit difficult to understand is that my original

                  response.write "counter=" & intHits

                  produced a number (with the embedded purple font) and this number was inserted into my dymanic text box, yet when I add 'visitors' to the script and change nothing at all in my FLA file, I get 'undefined'.

                  All very strange!

                  Steve
                  • 6. Re: 'No Show' in dynamic text box
                    robdillon Most Valuable Participant
                    When you are loading in new content from a server using LoadVars() the result is usually referenced as this.loaded. The loaded property of the LoadVars object is whatever was downloaded. So, in your case, you should use :
                    myVars = new LoadVars();
                    myVars.load("hitCount.asp");
                    myVars.onLoad = function(success){
                    if(success){
                    counter.htmlText = this.loaded
                    } else trace ("Error")
                    }

                    Let me know if that solve it.
                    • 7. Re: 'No Show' in dynamic text box
                      SteveH59 Level 1
                      Hello Rob

                      Thanks again for your help.

                      I managed to resolve this over the weekend, so haven't tried your script. I have saved it for reference purposes.

                      Using the following in ASP (stripped of its CSS tags):

                      response.write "counter=" & intHits & " <font color='#B3B3B3'>visitors</font>"

                      and this in the AS panel, it now works:

                      counter.html = true;
                      myVars = new LoadVars();
                      myVars.load("hitCount.asp");
                      myVars.onLoad = function(success){
                      if(success){
                      intHits = myVars.counter ;
                      } else {trace ("Error") ;}
                      }

                      And it looks good!

                      Many thanks again for your great efforts and for the time you have taken to help me.

                      Cheers

                      Steve