Simpel: variable within variable

hello generous flash experts,
please help me get some sleep again…
ive got two variables in _root:
var number = 1;
var url= ‘Pictures/Rotterdam/photo’+number;
buttons in my main movie change the values of these variables.
my next button looks like this:
on(press) {
number = number +1;
loadMovie(url);}
Problem:
loadMovie loads photo1 and thus has not used the new value for my number variable.
how do i write my url variable so that it has the new value?

on frame:


var count;
var url = 'home'+count+".swf";

on button:


on (press) {
_root.count = 2;
_root.loadMovie(url);
}

just substitute the default url for whatever you need the dynamic address to be. there was no need for you to assign a value to the count and simply increment it. just bring it to being and change it as necessary through your buttons.

also, its a root variable so it is probably best to address it as such. although you don’t have to because it will work either way, doing so can avoid possible problems.

hey,

thanx for the quick respons.
i do need to increment the count because its a sort of slide show. So everytime u click on next the number of the slide needs to increase.
also the url needs to change because there are different series.

maybe im missing something completely obvious to flash experts but i think this is the only way. Any other ideas?

Balthazar

dont know if this is how you want to do it, but i did it with a function.

on the frame:


//changeMovie function()
function changeMovie(operand) {
count += operand;
var url = 'home'+count+'.swf';
_root.pic.loadMovie(url);
}
//display 1st image
changeMovie(1);

on the button:


//call the changeMovie function
on (press) {
changeMovie(1);
}

the number will be automatically incremented one by the changeMovie function. changing 1 to 2, 2 to 3… you get the idea. that is just how i would do it. it makes things more easy and portable.

as for a back button, you could just make another function that will make it go back 1 number.


//call the changeMovie function, passing a -1 parameter to go back 
on (press) {
changeMovie(-1);
}

maybe i shoudnt have started this thread with simple…

My slideshow is part of a viewer which loads in external pictures in different folders.
If i could get my next button to work the way i have it set up it would mean i could use it for multiple functions. For example i could also set my url to be just the first picture in each folder and not increment the number each time. Ive tried many other set ups but none would be simpler on whole than how i have it now.

ive attached a quick test.fla which is what i need to work. please give it one more shot :confused: ?

hey forgot to put in the number+1 part

wouldn’t open…

you should have said all this when you asked your question.

is this possible?

var number = 1;
var url = ‘Pictures/photo’+number+’.jpg’;

on(press) {
number= number+1;
content.loadMovie(url);
trace (url);}

ouput: ‘Pictures/photo2.jpg’

no, it isn’t. when you use the var keyword, you are making a local variable (which can really only be used in functions.)

why does it load the first picture then? it seems to read the variables correctly but only in the wrong order.

is _global.variables an option?

Balthazar

ps i have to let u know i really apreciate this…

on frame:


var count = 1;

on button:


on (release) {
count++;
_root.pic.loadMovie("home"+count+".swf");
}
 

where pic is just a container i made to hold the loaded movie.

simpler, does the same thing you want and is more efficient.

it’s no problem, i just wish i could get this fixed…

my its because im sleepy (its past 1 in the morning here)…

I know the way u have it is simpler, i had like that before. The reason i want it my way is because it makes other functions ten times easier and simpler.

i understand if u give up this point. I think im going to sleep, if u have a sollution which somehow keeps the setup for var url, i will be delighted to read it in the morning!

Balthazar

its 6:11 pm