A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Randomize Size Question for leaf animation

  1. #1
    Senior Member
    Join Date
    May 2003
    Posts
    160

    Randomize Size Question for leaf animation

    i am making an animation of a tree with leaves blowing off the branches and can't seem to figure out how to randomize the size and guide offset of the leaves.

    here's what i have:

    a movieclip (leaves_mc) with a guide layer in it and a movie clip (leafanim_mc) attatched too it.

    what i want is to make the leafanim_mc scale large and small as it follows the guide path.

    since i don't want all the leaves to appear to follow the same path, i was trying to get the leafanim_mc movie clip to randomly offset in it's x and y while following the guide layer.

    basically i am trying to get a realistic blowing leaf without just making a bunch of motion tweens.

    can anyone help me figure this out? thanks!

  2. #2
    Flashkit Jedi

    Join Date
    Jul 2001
    Location
    Coruscant System
    Posts
    3,426
    Place this on the first frame of a clip to get random sizes:

    Code:
    _xscale = Math.random() * 100;
    _yscale = Math.random() * 100;
    Or you might want the width and height to be the same, so use this code:

    Code:
    _xscale = _yscale = Math.random() * 100;
    XFM

  3. #3
    Senior Member
    Join Date
    May 2003
    Posts
    160

    almost

    is there a way to make it have a range because the way it is it will scale really really small and really large.

    i would like it to only scale a small amount both ways.

    thanks for the help.

  4. #4
    Flashkit Jedi

    Join Date
    Jul 2001
    Location
    Coruscant System
    Posts
    3,426
    What you could do is set a number before hand like this:

    Code:
    randomsize = Math.random() * 70 + 30;
    See hown instead of * 100 I have put * 70 + 30? What this does is has a random number in between 0 and 70 and then plused by 30. So it is now a number in between 30 and 100.

    You can mess about with these numbers till you get what you want.

    XFM

  5. #5
    Senior Member
    Join Date
    May 2003
    Posts
    160

    re:

    thanks i'll try that out and see what happens.

  6. #6
    Flashkit Jedi

    Join Date
    Jul 2001
    Location
    Coruscant System
    Posts
    3,426
    Lemme know how it goes...

    XFM

  7. #7
    Senior Member
    Join Date
    May 2003
    Posts
    160

    re:

    that made it change in size like you said.

    maybe i didn't describe the effect i am looking to acheive well enough.

    i plan on having a tree on the right side of the screen and have leaves blow off of it. i know i can just motion tween a bunch of leaves, but file size would go way up if i do.

    what i want is to get the leaves to blow off the tree at random and have their size barely change bigger and small smaller as they blow, like a normal leaf would. i was also hoping to have them change up and down the screen within the area where the tree graphic is. i figured i could attach a movie clip to a motion tween and make it's y" offset change in relation to the motion guide.

    if this isn't possible i will have to use the tween method, but it seems like it is possible, i'm just driving myself nutts trying to figure it out.

    thanks for the help, hope we get this.

  8. #8
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113
    Perhaps you should be looking towards a sine / cosine math formula for having the leaves 'blow off' in a wave fashion. I'm sure you can find something here, at kirupa.com, maybe at were-here, bit-101 may have something. I have code at home that involves bubbles moving in a sine wave, so if no one helps you until then or you cannot find anything, I'll post the code.

    I'll probably post it anyway....
    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

  9. #9
    Senior Member
    Join Date
    May 2003
    Posts
    160

    re:

    thanks alot, i will look into those pages today!

  10. #10
    Senior Member
    Join Date
    May 2003
    Posts
    160

    re:

    i didn't get it working, i made another post with an attachment of the file that im testing this with, thanks.

  11. #11
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113
    How bout a link?

    And I downloaded the file... you have all the code in there for the moving...all you need is the duplication, right?
    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

  12. #12
    Senior Member
    Join Date
    May 2003
    Posts
    160

    re:

    http://www.flashkit.com/board/showth...hreadid=511331

    i need the stuff i posted on the above post, i got the duplication sort of working, but theres a bug.

    i would really like each leaf to duplicate as random as possible, at least their spawn positions, thank for the help, we'l get this figured out

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