how to update variable before being used

  • balthazar
  • Born
  • Born
  • balthazar
  • Posts: 2
  • Loc: Rotterdam

Post 3+ Months Ago

dear experts help me become more like you!

I have a 'next' button for a slideshow which i want to do the following:

on(press) {

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!

are _global variables an option?
  • joebert
  • Genius
  • Genius
  • User avatar
  • Posts: 13511
  • Loc: Florida

Post 3+ Months Ago

using _global will make an array "myURL" available anywhere as myURL, no _root _parent needed (be carefull not to use the same name for anything else).
Using an array instead of separate variables will allow you to update the number part of the array & use myURL.join("") to create a temp url to use. join("") creates a string from the elements of the array & places whatever is inside the quotes ("") between each element while leaving the array intact for future changes.
Code: [ Select ]
..... root ....
_global.myURL = ["photos/images", 0, ".jpg"];

..... on any mc ...
on(press) {
  //myURL[1] = 3; /* you can set it any way you want*/
  var URLtmp = myURL.join("");
  1. ..... root ....
  2. _global.myURL = ["photos/images", 0, ".jpg"];
  3. ..... on any mc ...
  4. on(press) {
  5.   myURL[1]++;
  6.   //myURL[1] = 3; /* you can set it any way you want*/
  7.   var URLtmp = myURL.join("");
  8.   content.loadMovie(URLtmp);
  9. }

The reason it worked when you put it in the loadMovie is it was redifining the url variable before it loaded, the way you have it now updates the number variable but not the url variable, you have to redifine the url variable after updating the number variable for the url variable to reflect a new value.
  • balthazar
  • Born
  • Born
  • balthazar
  • Posts: 2
  • Loc: Rotterdam

Post 3+ Months Ago

thanx a lot.

ive posted this question in many forums but up till now all ive gotten are suggestions which ignore half the things i asked to make my setup work.
I had come up with a temporary solution which uses another variable to toggle wether my next button uses one url or the url but this is alot simpler.


Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.