forked from: HUSH HUSH
EARLY RUN - MOSTLY UNFINISHED
CLICK ON STAGE TO HIDE OR DISPLAY ANGLE LINES
BAD LINES IN ORIGINAL CODE
-> FOLLOWING LINES PROVIDE CURVY & FALSE POSITION
ENDED TRANSLATION NEVER REACH point.x / point.y
-----------------------------
x += (point.x - x) >> speed;
y += (point.y - y) >> speed;
-----------------------------
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dwcZ
*/
// forked from spanvega's HUSH HUSH
// forked from jancassio's Simple random 2D position
package
{
/*
* EARLY RUN - MOSTLY UNFINISHED
* CLICK ON STAGE TO HIDE OR DISPLAY ANGLE LINES
*
* BAD LINES IN ORIGINAL CODE
* -> FOLLOWING LINES PROVIDE CURVY & FALSE POSITION
* ENDED TRANSLATION NEVER REACH point.x / point.y
* -----------------------------
* x += (point.x - x) >> speed;
* y += (point.y - y) >> speed;
* -----------------------------
*/
import flash.geom.Point;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Shape;
import flash.display.Sprite;
import flash.utils.setInterval;
[ SWF (width = '465', height = '465', backgroundColor = '0xFFFFFF', frameRate = '25') ]
public class HUSH_HUSH extends Sprite
{
private var dot_vec : Vector.<Dot>;
private var dot_num : uint = 25;
private var dot_fac : Sprite;
private var dot_lin : Sprite;
private var dot_ang : Sprite;
//
private var show_line : Boolean = true;
private var stageW : Number;
private var stageH : Number;
//
private var dots : Sprite = new Sprite ();
public function HUSH_HUSH ()
{
stage ? init () : addEventListener (Event.ADDED_TO_STAGE, init);
}
private function init () : void
{
if (hasEventListener (Event.ADDED_TO_STAGE))
{
removeEventListener (Event.ADDED_TO_STAGE, init);
}
stage.scaleMode = 'noScale';
stage.addEventListener
(
MouseEvent.CLICK,
onClick
);
stageH = stage.stageHeight;
stageW = stage.stageWidth;
//
dot_lin = new Sprite ();
// addChild (dot_lin); // UNUSED FOR THE MOMENT
//
dot_ang = new Sprite ();
addChild (dot_ang);
//
dot_fac = new Sprite ();
addChild (dot_fac);
//
dot_vec = new <Dot> [];
for (var i : int = 0; i < dot_num; i++)
{
var d : Dot = new Dot
(
new Point
(
stageH / 2,
stageW / 2
)
);
dot_fac.addChild (d);
dot_vec.push (d);
}
//
addEventListener (Event.ENTER_FRAME, onEnterFrame);
setInterval (onInterval, 2500);
//
onInterval ();
}
private function onEnterFrame (e : Event) : void
{
dot_ang.graphics.clear();
for each (var d : Dot in dot_vec)
{
d.move ();
// --o DRAW ANGLE LINES
var px : Number = d.x;
var py : Number = d.y;
dot_ang.graphics.lineStyle(1, d.color, 0.75);
dot_ang.graphics.moveTo (mouseX, mouseY);
dot_ang.graphics.lineTo (px, py);
// --o CALC BEVEL FILTER ANGLE
var degrees : Number = Math.atan2
(mouseY - py, mouseX - px) * (180 / Math.PI);
d.bevel.angle = degrees;
}
}
private function onInterval () : void
{
// dot_lin.graphics.clear ();
for each (var d : Dot in dot_vec)
{
// dot_lin.graphics.moveTo (d.point.x, d.point.y);
// --o CHECK WHEN TRANSLATION IS COMPLETE ..
d.point = new Point
(
d.width /2 + (Math.random () * (stageW - d.width)),
d.height /2 + (Math.random () * (stageH - d.height))
);
// MOVE LINES
// dot_lin.graphics.lineStyle (.5, d.color, .5);
// dot_lin.graphics.lineTo (d.point.x, d.point.y);
}
}
private function onClick (e : MouseEvent) : void
{
// dot_lin.visible = !dot_lin.visible;
dot_ang.visible = !dot_ang.visible;
}
}
}
import flash.geom.Point;
import flash.display.Sprite;
import flash.filters.GlowFilter;
import flash.filters.BevelFilter;
class Dot extends Sprite
{
private var _color : uint;
private var _point : Point;
private var speed : uint = 5;
private var _glow : GlowFilter;
private var _bevel : BevelFilter;
public function Dot (p : Point)
{
// color = 0xFF0000 * Math.random ();
color = 0x000000;
glow = new GlowFilter (color);
bevel = new BevelFilter
(
10, 45, 0xFFFFFF, .15, 0xFFFFFF, 0.75, 6, 6
);
filters = [bevel, glow];
graphics.lineStyle (2, 0xFFFFFF);
graphics.beginFill (color, 1);
graphics.drawCircle (0, 0, 5 + Math.random () * 25);
graphics.endFill();
point = p;
//
x = point.x;
y = point.y;
}
public function move () : void
{
x += (point.x - x) >> speed;
y += (point.y - y) >> speed;
//
filters = [bevel, glow];
}
//
public function set point (p : Point) : void
{
_point = p;
}
public function get point () : Point
{
return _point;
}
public function set color (n : uint) : void
{
_color = n;
}
public function get color () : uint
{
return _color;
}
// --o FILTERS
public function set glow (g : GlowFilter) : void
{
_glow = g;
}
public function get glow () : GlowFilter
{
return _glow;
}
//
public function set bevel (b : BevelFilter) : void
{
_bevel = b;
}
public function get bevel () : BevelFilter
{
return _bevel;
}
}