A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Randomness?

  1. #1
    Junior Member
    Join Date
    Jun 2001
    Posts
    9
    I would like to have a movie clip called "line" choose a new x value every 2 seconds... is there any way to make it (every 2 seconds) generate a random #, make that an x value and replace the movie clip there?

    Please help!
    Thanks
    Relcon

  2. #2
    Junior Member
    Join Date
    May 2001
    Posts
    11

    hmmm

    i guess you would just write a script that would do the math 2 figure out a random number for the x coord. you could make the line an mc. (give an instance name)

    place the actions inside of the mc using an 'onClipEvent' - EnterFrame (choose this so that it keeps repeating and getting a new coord number from the script)

    does that make sense? i bet someone else could explain that better.


    anyway. that's how i would do it.


  3. #3
    Junior Member
    Join Date
    Jun 2001
    Posts
    9

    Post could you type in an example?

    could u add in an example of what the actionscript would look like?

    Thanks
    Relcon

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    168
    I don't know the exact code but here's an idea.

    Let's say your movie is running at 20 frames per second. Then in your mc set a variable for a counter.

    var counter = 0

    then put a conditional inside an enterframe onClipEvent.

    so... onClipEvent (enterFrame) {
    if (counter == 40) {
    //your duplicating and randomness code here;
    counter = 0;
    }
    else {
    counter ++;
    }

    So theoretically every time the mc enters a frame it will increment the counter variable and in 2 seconds it will reach 40 and then execute the code inside your conditional.

    I haven't done this but I think it can work.

    I hope that helps you a little.

    Dan

  5. #5
    Junior Member
    Join Date
    May 2001
    Posts
    11

    yeah

    um...yeah...what that guy said.

    hey Dan. you are obiviously a genius. can you please help me with the thread i just posted about preloading? it's a few down. i really need some help.

    thanks

  6. #6
    Junior Member
    Join Date
    Jun 2001
    Posts
    9

    Smile sweet idea

    wow
    now im happy
    thanks a bunch man (my name is dan too, it was wierd when that guy called u a genius... i thought he meant me for a sec.!)
    hehe
    alright
    thanks a bunch!!!

    Relcon

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