# Updating a variable before it is used

**URL:** https://forum.kirupa.com/t/updating-a-variable-before-it-is-used/121591
**Category:** Uncategorized
**Created:** [September 4, 2004, 7:39am UTC](https://forum.kirupa.com/t/updating-a-variable-before-it-is-used/121591 "2004-09-04T07:39:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![balthazar](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@balthazar](https://forum.kirupa.com/u/balthazar)
#### Post date: [September 4, 2004, 7:39am UTC](https://forum.kirupa.com/t/updating-a-variable-before-it-is-used/121591/1 "2004-09-04T07:39:55Z")

</div>

dear experts help me become more like you!

Things have become a lot clearer for me since my last post so i hope this second attempt will make it easier for u to answer:  
I have a ‘next’ button for a slideshow which i want to do the following:

on(press) {  
\_root.Number=\_root.Number+1;  
content.loadMovie(\_root.Url);  
}  
where my variables have been defined in a Frame as:  
var Url = ‘Pictures/photo’+Number+’.jpg’  
var Number= 1;

The reason i have used the variable Number in my Url variable and not directly in the loadMovie target (which does work) is that i want to be able to sometimes change the variable Url. Eg. when a user clicks on a series button such as ‘Cities’ i could get the next button to cycle through the first picture in each series in my array serie[]:  
\_root.url = ‘Pictures/serie[Number]’+photo1.jpg

the problem remains that my next button continues to use the old value for number so i get the same image over and over again.  
Anybody have any ideas??

thanxs a lot in advance!
