July 16

The SWF

Read more for code and source files

The Class

package com.lynda.particles{
	import flash.display.*;
	import flash.filters.BitmapFilter;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.BlurFilter;
 
	public class Particle extends Sprite {
		public var xVelocity:Number;
		public var yVelocity:Number;
 
		public function Particle() {
			xVelocity=0;
			yVelocity=0;
		}
 
		public function update():void {
			this.x+=xVelocity;
			this.y+=yVelocity;
		}
	}
}

The Movie Actionscript (AS3)

var numOfParticles:uint=10; // For the ribbon
var maxVelocity:Number=8;
var minVelocity:Number=1;
var particles_ary:Array=[];
 
var numOfParticles2:uint=40; // For the short ribbon
var particles2_ary:Array=[];
var maxVelocity2:Number=5;
var minVelocity2:Number=1;
 
var  myColor:ColorTransform = this.transform.colorTransform; //for both
 
function updateStage(event:Event):void {
 
if (particles_ary.length< particles_ary.length; i++) { //set repeat conditions for when particles go off stage var particle:MoveAsset2=particles_ary[i]; var c:ColorTransform = new ColorTransform(); c.color = (Math.random() * 0xFFFFFF); particles_ary[i].update(); if (particle.y>stage.stageHeight+particle.height/2) {
particle.yVelocity = Math.floor(Math.random() * (maxVelocity -  minVelocity)) + minVelocity;
particle.x = Math.floor(Math.random() * ((stage.stageWidth - (particle.width)) -  (particle.width))) + (particle.width);
particle.y=0;
particle.scaleY = particle.scaleX = Math.floor(Math.random() * (3 -  0) + 0);;
 
particle.ribbon_mc.ribbon_mc.color_mc.transform.colorTransform = c;
 
trace("scale = " + particle.scaleX);
if (particle.scaleX||particle.scaleY>1){
particle.alpha = Math.random()* .8 + .2;
}
 
}
}
}
 
addEventListener(Event.ENTER_FRAME, updateStage); // listening
 
function updateStage2(event:Event):void {
 
if (particles2_ary.length< particles2_ary.length; i++) { var particle1:MoveAsset1=particles2_ary[i]; var c:ColorTransform = new ColorTransform(); c.color = (Math.random() * 0xFFFFFF); particles2_ary[i].update(); if (particle1.y>stage.stageHeight+particle1.height/2) {
particle1.yVelocity = Math.floor(Math.random() * (maxVelocity2 -  minVelocity2)) + minVelocity2;
particle1.x = Math.floor(Math.random() * ((stage.stageWidth - (particle1.width)) -  (particle1.width))) + (particle1.width);
particle1.y=0;
particle1.scaleY = particle1.scaleX = Math.floor(Math.random() * (3 -  0) + 0); // change the scale
 
particle1.confetti_mc.color_mc.transform.colorTransform = c;
trace("scale = " + particle1.scaleX);
if (particle1.scaleX||particle1.scaleY>1){
particle1.alpha = Math.random()* .8 + .2; // change the alpha channel according to scale
}
 
}
}
}
 
addEventListener(Event.ENTER_FRAME, updateStage2);

The FLA Source File

Download the FLA source File

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.