A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: CS3: Random videos

  1. #1
    Member
    Join Date
    Aug 2003
    Location
    Texas
    Posts
    82

    CS3: Random videos

    Could someone please guide me in the right direction on how to play videos randomly? For example, if I have 5 videos in a flash file, how can I make the player play the 5 videos randomly on every page refresh?
    Thank you for your time
    Ghost

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Location
    Ljubljana, Slovenija
    Posts
    168
    I have not tested this code, I give it just to ilustrate:



    var myList:Array = new Array(myVid1, myVid2, myVid3, myVid4, myVid5);
    var i = Math.floor(myList.length * Math.random());
    var randomVideo:Video = myList[i];

    and than you use randomVideo for whatever you need.

    Hope this helps

  3. #3
    Member
    Join Date
    Aug 2003
    Location
    Texas
    Posts
    82
    Quote Originally Posted by malcek View Post
    I have not tested this code, I give it just to ilustrate:



    var myList:Array = new Array(myVid1, myVid2, myVid3, myVid4, myVid5);
    var i = Math.floor(myList.length * Math.random());
    var randomVideo:Video = myList[i];

    and than you use randomVideo for whatever you need.

    Hope this helps
    Thank you for your help and I copied the code down and tested 2 videos, but they both play at the same time. Am I supposed to replace any thing in the code? I'm sorry, I am very new to AS2.
    Thank you
    Ghost

  4. #4
    Member
    Join Date
    Aug 2003
    Location
    Texas
    Posts
    82
    Oh by the way, the code needs to be in AS2.
    Thank you
    Ghost

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