SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random image, but in Flash.

    I'm sure this is easy, but I'm not sure how to do it. I need to do a movie with a little cartoon character whose speech bubble is different every time it's reloaded (I have 18 different variations). How in Flash can I randomise the appearance of these 18 speech bubbles?

    G

  2. #2
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    use the random() function to do this
    Learn the best flash tutorials on the net from advanced to basic worth a visit also flash games to play http://www.flashcircle.com
    The Best articles On The Net Amazing Stories - Free Greetings

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought that would be the one. Flashwami showed it to me before, but would it be rand(18) if you have 18 options ... would that be right?

    G

  4. #4
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. I just found another example of random() being used and I'm pretty sure I know what to do now (not sure about syntax but I'll suss it!) :

    Code:
    function randomspeech() {
    r=random(18)
    loadMovie("speech" add r add ".swf", 0)
    }
    Am I right?

    G

  5. #5
    ...
    Join Date
    Jan 2002
    Location
    London, UK
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey greg,

    r=random(18) will return a number between 0 and 18 - r=random(17) is the one to use for 18

    If your setting up your movies for Flash 5 + players its best to use:

    r=Math.round(Math.random()*17) as random() is depreciated, meaning it may not be supported with future versions of the Flash player

  6. #6
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers fella! Of course!! *slaps head* Same as VBS. Saved me finding that out the hard way!

    I may back-version it for the time being, but have that code on the back burner and ready to throw in.

    G

  7. #7
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use this one to load a random swf into a main swf..

    ---
    // Set the variable that will contain a random number to 0
    var load_swf_num = 0;
    // While it is equal to zero have it keep grabbing a random variable
    while (load_swf_num == 0) {
    // Choose a random Integer up to 4
    var load_swf_num = int(random(4));
    }
    var swf_prefix = "swf";
    var swf_sufix = ".swf";
    loadMovie (swf_prefix + load_swf_num + swf_sufix, "_root.loader");

  8. #8
    SitePoint Zealot flashswami's Avatar
    Join Date
    Jun 2002
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Chas is absolutley right Greg- I should've told you about the math.random object/method the first time [slaps self]
    FlashSwami //Flash & server side fun
    DotDragNet //General web help
    [>Now available for freelance web work<]


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •