I am playing around trying to teach myself actionscript and I’m getting frustrated with a simple dynamic textbox. I have a main movie with just one frame and in the frame actionscript I have :
newitemwidth;
totallength = 10 + newitemwidth;
I have a button on this main movie that on release, among other things, has:
newitemwidth = 115;
I have a dynamic textbox on the movie as well with the variable set to:
totallength
When I test the movie, the textbox shows 10, but when I click the button it doesn’t change to 125 with the added newitemwidth. Am I missing some rule about global variables here? Thanks for your help.
You must take note of where the variable was declared. Supposing that newitemwidth is on the main timeline, you can target it by either using absoluate addressing (_root for example, which is evil :P) or relative addressing (_parent for example). So use _root.newitemwidth on release of the button instead of newitemwidth. If you do not target an exisitng variable, a new one will be created.
Also, you might want to update the textbox. It’s not because you set the textbox to display newitemwidth once, that it’ll display it forever. You’ll also have to update totallength if you’re displaying totalllength. So use this: