Age/Gender: n/a, Male
Location: New Mexico
Job: Student
Rusty Air.
Newgrounds Stats
Whistle Status: Garbage
Exp. Points: 590 / 710
Exp. Rank #: 64,712
Voting Pow.: 5.00 votes
BBS Posts: 671 (0.92 per day)
Flash Reviews: 2
Music Reviews: 0
Trophies: 0
Stickers: 0
Entry #6
Pretty strait-forward. I made snow; complete with glowing.
____________________
Script:
In the main frame panel:
var pressing:Boolean = true;
var timer:Number = 0;
var gf:Number = .25;
var fr:Number = .8;
function onEnterFrame():Void {
timer++;
if (timer%15 == 0) {
var dot:MovieClip = attachMovie("dot", "dot"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
dot._x = Math.random()*Stage.width;
}
}
function onMouseDown():Void {
pressing = !pressing;
}
In the "white dot" MovieClip :
import flash.filters.GlowFilter;
var vx:Number = 0;
var vy:Number = 0;
function onEnterFrame():Void {
var glow:GlowFilter = new GlowFilter(0xFFFFFF, 1, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, 3, 3, false, _root.pressing);
this.filters = [glow];
vy += _root.gf;
vx *= _root.fr;
vy *= _root.fr;
_x += vx;
_y += vy;
if (_y>Stage.height) {
removeMovieClip(this);
}
}
____________________
Explanation:
var pressing:Boolean = true;
var timer:Number = 0;
Initiatives.
var gf:Number = .25;
var fr:Number = .8;
Physics control. I used a single, _root variable instead of one in every "snowflake" to reduce lag.
function onEnterFrame():Void {
timer++;
if (timer%15 == 0) {
var dot:MovieClip = attachMovie("dot", "dot"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
dot._x = Math.random()*Stage.width;
}
}
Creates a "snowflake" every 15 frames.
function onMouseDown():Void {
pressing = !pressing;
}
Determines if you have clicked.
import flash.filters.GlowFilter;
Sets up glow effect.
var vx:Number = 0;
var vy:Number = 0;
Init.
function onEnterFrame():Void {
var glow:GlowFilter = new GlowFilter(0xFFFFFF, 1, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, Math.sqrt((_x-_root._xmouse)*(_x-_root ._xmouse)+(_y-_root._ymouse)*(_y-_root ._ymouse))/50+2, 3, 3, false, _root.pressing);
this.filters = [glow];
Adds the glow and sets the glow amount based on how far the mouse is from the "flake".
vy += _root.gf;
vx *= _root.fr;
vy *= _root.fr;
Gravity and friction.
_x += vx;
_y += vy;
Moving the MovieClip.
if (_y>Stage.height) {
removeMovieClip(this);
}
Deletes the MovieClip if it is below the screen.
}
Copyright 2008 Ryan Keathley.
Updated: 01/31/08 10:53 PM Log in to comment! | Share this!The People Have Spoken
2 Comments