Create a snowflake in Flash
Thursday, December 6th 2007Some readers me have asked as was created the snowflake, so realistic, the Widget natalizio. Who downloaded the source probably already knows ... anyway was really simple. Firstly I selected Tool Pennello in Flash and I designed a point.
![]() | ![]() |
Ho transformed this in a symbol me show applied two effects in right sequence: chamfering and blur:
![]() | ![]() |
The result was: 
Here MovieClip (symbol) ho associated a simple class CNeve which creates facto intelligence Jib same:
- _interval ; private var _interval;
- / /
- function CNEVA () (
- this , "_move" , 25 ) ; _interval = setInterval (this, "_move", 25);
- )
- / /
- _getRndRange ( min : Number , max : Number ) : Number { private function _getRndRange (min: Number, max: Number): Number (
- return randomNum;
- )
- / /
- _move ( ) { private function _move () (
- 1 , 5 ) ; _y + = _getRndRange (1, 5);
- _getRndRange ( - 50 , 50 ) ) > 0 ) ? 1 : - 1 ; _x + = ((_getRndRange (- 50, 50))> 0)? 1: - 1;
- 1 , 5 ) ; _rotation + = _getRndRange (1, 5);
- _y > _maxy ) { if (_y> _maxy) (
- _interval ) ; clearInterval (_interval);
- )
- ; updateAfterEvent ();
- )
- )
Method _move() contains intelligence Jib, namely function of fall, extremely simple. Varying the function random, _x += ((_getRndRange(-50, 50))>0) ? 1 : -1;, _x += ((_getRndRange(-50, 50))>0) ? 1 : -1;, eg inserting a _getRndRange(-550, 50), you may add an effect effect wind, ie the flakes fall with a gradient particular. Specifically you can send i flakes right and left using a code this type:
- _getRndRange ( _getRndRange ( - 350 , - 50 ) , _getRndRange ( 50 , 350 ) ) ) > 0 ) ? 1 : - 1 ; _x + = ((_getRndRange (_getRndRange (- 350, - 50), _getRndRange (50, 350)))> 0)? 1: - 1;
Rotation _rotation += _getRndRange(1, 5); then, confers an further detail to staple same.
When creo a jib (see function creaFiocco() below) ho added also a alpha=90 and one stairs randomly, for have snowflakes of different dimensions.
- / / Creates staple
- function creaFiocco () (
- 20 , 100 ) ; var s = randRange (20, 100);
- "neve" , "neve_" + index , index , { _x : x , _y : y , _xscale : s , _yscale : s , _alpha : 90 } ) ; c_mc. attachMovie ( "skiing, neve_" + index, index, (_x: x, _y: y, _xscale: s, _yscale: s, _alpha: 90));
- index + +;
- index > 1000 ) { if (index> 1000) (
- ; index = 1;
- , 2 ) ; c_mc = createEmptyMovieClip ( "c_mc", 2);
- )
- )
That is everything ...
Forgot ... Auguri to all and Buone feasts ... ![]()

















Check my site: http://www.Dieg0.com.ar
Regards,
Diego
@ Diego0: Thanks for links
Sul site of Diego find one script Javascript that simulates also falling of snowflakes. The advantage using Javascript is being able positioning pompons above to our page, thing with Flash - whilst is possibiloe through transparency - ne prevents then facto selecting.
Hello It should son came to to pry seeing you in mybloglog on my blogghetto. Are precisely ignorant regarding flash and surroundings, not knew had OOP action script. Who knows when succeed in darci un'occhiata, the thing attracts me
Hello hello
@ Chris: thanks for visiting! Saw that ti're Commentary in programming OO with C + +! Ottima choice. To tackle well concepts OO must surely know well both the C that C + +. Actionscript not so pure "like C + +, although at each version approaches increasingly to true and" narrow "development methodologies OO. Anyway if Can working with Flash, even in Actionscript 2.0, you surely find many things illuminants.
[...] Aggiornamento: service unavailable - See Create a snowflake snow in Flash [...]
«At this MovieClip (symbol) ho associated a simple class CNEVA, which creates facto intelligence of ...»
Hai started easily and with illustrations clearest, then you skipped a tot information essential for a user "standard": how you creates class
CNeveSaw how joins to symbol, but I lack everything else. Mi arrangera differently but é a sin.@ Claudio: What not ti is clear exactly? Sometimes may seem that jump few dettaglio However Whereas an side certain "bases" owe assume otherwise should write a handbook every post and secondly can find many clarifications previous post that always find here following eg the category ActionScript 3.0 or Flash. Anyway class
CNeveis associated to a MovieClip vacuum present in libreria via the window property. For details see eg Actionscript 3.0: everything with the operator new. If other doubts scrivimi pure, I will happy to answer so toecap.