# Adding to variable from within movieclip

**URL:** <https://forum.kirupa.com/t/adding-to-variable-from-within-movieclip/317572>\
**Category:** Uncategorized\
**Created:** [December 24, 2010, 10:53pm UTC](https://forum.kirupa.com/t/adding-to-variable-from-within-movieclip/317572 "2010-12-24T22:53:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashermx](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@flashermx](https://forum.kirupa.com/u/flashermx)\
**Post date:** [December 24, 2010, 10:53pm UTC](https://forum.kirupa.com/t/adding-to-variable-from-within-movieclip/317572/1 "2010-12-24T22:53:23Z")

</div>

Using AS 3.0 I have declared a variable on the maintimeline  
var thescore:int=0;

From within a movieclip I now want to increase the value of that variable and display it in a text box.

var thescore:int=thescore+10;  
Object(root).myscore.text=thescore.toString();

The above code only displays ten and doesn’t increase when the movieclip loops.

If I change the code to  
thescore=thescore+10;  
Object(root).myscore.text=thescore.toString();

I receive an error undefine property

Any help would be appreciated.
