<? XML version = "1.0" encoding = "UTF-8"?>
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009"
Xmlns: S = "Library: // ns.adobe.com/flex/spark"
Xmlns: MX = "Library: // ns.adobe.com/flex/mx"
Applicationcomplete = "calllater (init )"
Width = "500" Height = "375">
<S: layout>
<S: basiclayout/>
</S: layout>
<FX: style source = "assets/snow.css"/>
<FX: declarations>
<! -- Place non-visual elements (such as services and value objects) Here -->
</FX: declarations>
<FX: SCRIPT>
<! [CDATA [
Import MX. Core. uicomponent;
Import tea. Snowflake;
Private var snowarr: array;
Private var snownum: number;
Private function Init (): void {
Snowarr = new array ();
// Create snowflake
VaR snow: snowflake = new snowflake ();
Snow. x = 50;
Snow. Y = 50;
VaR UI: uicomponent = new uicomponent ();
Ui. addchild (Snow );
BC. addelement (UI );
}
]>
</FX: SCRIPT>
<S: bordercontainer id = "BC" x = "0" Y = "0" width = "500" Height = "375">
</S: bordercontainer>
</S: Application>
Snowflake class
Package tea {
Import flash. display. Sprite;
Public class snowflake extends sprite {
Private var radius: number;
Private var color: number;
Public Function snowflake (radius: Number = 5, color: Number = 0 xffffff)
{
This. radius = radius;
This. Color = color;
Drawsnow ();
}
Public Function drawsnow (): void {
Graphics. beginfill (this. Color, 1 );
Graphics. drawcircle (0, 0, this. radius );
Graphics. endfill ();
}
}
}