-
Here's the question:
If I have a variable x getting a random number
ie. x = Math.random()
How do I get the value of x to show up in a loadMovie URL?
ie. mymovie.swf?x
(I want x to be the random number, instead of it interpreting it as the actual letter x)
Any suggetions would greatly appreciated. Thanx.
-
Use the following:
x = Math.random();
url = "MyFile.swf?"+x;
Then use url in your loadMovie action.
i.e. loadMovie(url);
You could also use getTimer() to have different numbers each time you make the loadMovie call.
getTimer() returns the number of milliseconds that have elapsed since the movie started playing.
url = "MyFile.swf?"+getTimer();
If you really want to make sure the number added to your url is unique, use the date object.
First define a new date object:
myTime = new Date();
then use the getTime() property (different from getTimer()!!) to get the amount of milliseconds elapsed since January 1 1970..
url = "MyFile.swf?"+myTime.getTime();
Make sure evertime you re-initialize url, re-initialize myTime too, since myTime doesn't update itself..
HTH
mcBassTN
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|