I understand, that this code does not work , as you can not set the width like that. What I don‘t understand is, what you try to do. What the effect of this should be.
RIGHT does not work (I don’t know why). And you need to set that BEFORE you update the data (before the for each loop) otherwise it will do nothing. Then after the data is set, the width of the textField (not the movieClip) reflects the textlenght. Now you need a way to adjust the length of the background. I usually use a mask, that I move based on the width of the textField, as when you scaleX the whole movieClip the text will get distorted. Then the scaleX of the whole movieclip (including the mask layer etc.) is only used for the animation effect.
Please read carefully, what I said. And be sure to not mess up the setting of the size for the variable sized background and the animation effect. They have nothing to do with each other. It could also be animating alpha from 0 to 1 or anything else. You first set up the text and background. THEN set the scaleX to 0 to let the animation effect do his job…