4 Replies Latest reply on Nov 18, 2008 11:50 PM by Chunick

    Continuous control of text sprite's text

    miche_r Level 1
      I have a database project and database values are shown in text sprites. However, empty entries in database are shown as "null" text in sprites, and I'd like to remove that. Currently I have done that with enterframe function (which checks the values in text sprites and removes "null" texts). It works, but the "null" texts blinks for a second in the sprites before they're removed. Is there a way that I could control text sprites all the time, and remove "null" texts immediately?
        • 1. Re: Continuous control of text sprite's text
          robdillon Most Valuable Participant
          It sounds like you're testing for null after the text is updated. You want to find the place in your code where the new value from the DB is set into text. Test for null there.
          • 2. Re: Continuous control of text sprite's text
            James Newton, ACP Level 3
            How, when and where does your code add the "null" entry to the text sprite? That's the moment to check the value of the entry. Here's some pseudo-code:

            if myDatabaseEntry = "null" then
            myTextMember.text = ""
            myTextMember.text = myDatabaseEntry
            end if
            • 3. Re: Continuous control of text sprite's text
              miche_r Level 1
              The values are entered in enterframe and I can build the value checking to the phase when the database value is put to the text member. I was just wondering if there is some simple option, because I have 50 text sprites each with separate "enter this database value to this sprite" code.
              • 4. Continuous control of text sprite's text
                Chunick Level 3
                start learning about behaviors, scope, OOP programming and how Director handles OOP, and then you'll see the benefits to attaching behaviors to sprites, parent scripts and movie scripts.

                The reason why a frame script is a bad idea (if you're using frame scripts or even if you're using on enterframe handler in a behavior script) is that if you looped on that frame or the playhead passed over that frame several times then the code would be called repeatedly unless a conditional was put in place to control that... in which case I would then think to myself there's probably a better way to do this... the type of code you want to put in an on enterframe or frame script is code that typically needs to be updated every frame such as moving a sprite on the stage or changing it's colour, or checking the status of some sprite property, for instance... what you want to use is a movie script or a parent script with some behavior scripts attached to your text sprites as listeners... so, your movie or parent script would do all the difficult database stuff and then it would send the appropriate message and data to the text sprites.