FORUMS: list search recent posts

# Snowglobe

FAQ   •   VIEW ALL
 Snowglobe on Dec 12, 2008 at 11:43:45 am

Oh yes, it's that time of year!

I'm having a go at doing the company christmas card. I'll just outline the idea then go into detail about how I'm approaching it and where I'm running into problems.

The company staff (4) are sat in the office with santa hats and stockings.
The camera crashes out to reveal that they are encased within a snowglobe.
Snow is falling and settling in the globe and the viewer(user?) can click and drag to 'shake' the snowglobe and get the snow moving again.

-----

The first section is basically done and elements are being prepped for the intereactive flash bit. None of that's a huge problem.

The way I am trying to do the snowglobe bit is as follows.

I got a bit of actionscript for falling snow from
http://www.kirupa.com/developer/mx2004/snow.htm
I've then built from there.

There are a few main hurdles to get over:
1. containing the snow within the globe
2. having the snow settle
3. having the snow move when 'shaken'

------
==1==

To contain the snow in the globe I am trying to define a circfular area using the function x^2+y^2=radius. So I look at the y position of each snowflake and check if it is outside the area thus:

centre=width/2;
//centre of the stage
if (this._x>centre){
//if the snowflake is on the right-hand side of the stage
if (this._x>xedge){
//if the snowflake is past this edge
if(this.wind>0){
//check it's on its way out
this.wind*=-1;
//flip direction
}
if (this._alpha=100){
this._alpha=50;
}
//change opacity to differentiate between background and foreground
}
}else....
and the same but reversed for the other side of the stage.

This doesn't actually work though. If anyone can see a reason why that would be good.
------
==2==
The snow settles fine. I do this by checking if the y meeets criteria (has hit the bottom) and then removing all downward and sideways force.

-----
==3==
Moving the snow when shaken.... well, that's tricky.

I only have an idea in my head of how this might work, if people could suggest methods I oculd use to achieve it that would be great.

When clicked and dragged a movement speed is worked out.

This speed is then applied to all snowflakes in an additive way

So if I move the globe at 1 pixel/frame down the speed will be 1 in the y.

Each snowflake will then have its y speed adjusted by -1. So now all the snowflakes will be moving, thus unsettled.

I haven't got this to work yet, but if anyone takes an interest and gets it to work I'll be very appreciative.

I'll post if I get any further with it.