dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: random balloon animation. help please.

  1. #1
    Junior Member
    Join Date
    Dec 2004
    Posts
    5

    random balloon animation. help please.

    I am trying to do animation where is balloons floating from down to up. This is much like a popular snowflakes animation but upside down. And I have tried to convert some of them into this balloon thing that is now looking like this:
    http://koti.mbnet.fi/leeko/pics/balloony.html

    But there are 2 problems.
    First the smaller balloons (that should be behind the bigger ones) sometimes float infront of the bigger ones.

    Secondly I would like that the picture of each balloon is randomly selected from about 10 different possibilities. So there would be more variety in this thing.

    Now there is loop in Layers actions witch duplicates this balloon movieclip. And in that movieclips actions has the script that makes it float etc.

    Any ideas?

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    If you post the script you are referring to, we can help you improve it.

    In general, you want to use swapDepths() on each movieclip to assign a depth corresponding to it's size (larger balloons get larger depth numbers).

    Here's a trick to put larger balloons in the front (do this to each balloon, in the loop, after scaling it).

    balloon.swapDepths(10+balloon._width);

    If each balloon has 10 frames corresponding to different logos, you can use

    balloon.gotoAndStop(random(10)+1);

    to make it select a logo.

    * * *


    There is a trick you can use to make the smaller balloons in the back move slower, giving the motion a 3D look.

    You create a random 'z' coordinate, and then use the following equation for scaling all the properties:

    zScale = focalLength / (focalLength+z);

    For example:
    code:


    focalLength = 300;
    z = random(1000);
    zScale = focalLength / (focalLength+z);

    balloon._xscale = balloon._yscale = 100*zScale;
    balloon.speed = 20*zScale;
    balloon.swapDepths(1000*zScale);

    Last edited by jbum; 12-16-2004 at 02:59 PM.

  3. #3
    Junior Member
    Join Date
    Dec 2004
    Posts
    5
    Thanks!!
    Got it working now

  4. #4
    Senior Member
    Join Date
    Feb 2004
    Posts
    133
    Leeko,

    Could you please let me take a look at your code or fla? I am trying to achieve the same effect...

    Thanks!

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