A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: need some help with my syntax

  1. #1
    Junior Member
    Join Date
    Jul 2001
    Posts
    3
    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.

  2. #2
    sucker for code
    Join Date
    Mar 2001
    Posts
    38
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center