Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.Bitmap;
- import flash.display.Sprite;
- import flash.events.Event;
- import interfaces.ISprite;
- [SWF(width="600", height="400", backgroundColor="#cccccc", frameRate="60")]
- public class Main extends Sprite
- {
- private var _flakeList:Array;
- public function Main()
- {
- createWinter();
- createFlakes(5);
- }
- private function createWinter():void
- {
- var bg:Bitmap = new Bitmap(new Winter(0, 0) ); //instantiate bitmap
- this.addChild(bg); //add bitmap to screen
- }
- private function createFlakes(amt:int):void
- {
- _flakeList=[]; //instantiate array
- //loop to create flakes using var passed from above to determine how many
- for (var i:int=0; i<amt; i++)
- {
- var flake:Snowflake2 = new Snowflake2();
- flake.x = 50 + i*70; //position flakes across x axis
- flake.y = 50;
- flake.scaleX = flake.scaleY = .25; //scale flakes to 25%
- this.addChild(flake); //add flakes to screen
- _flakeList.push(flake);
- }
- this.addEventListener(Event.ENTER_FRAME, update);
- }
- private function update(e:Event):void
- {
- //trace("work");
- //loop thru array of flakes, run update for each one
- for each(var flake:ISprite in _flakeList)
- {
- flake.update();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment