flash on 2012-12-20
♥0 |
Line 183 |
Modified 2012-12-22 03:50:30 |
MIT License
archived:2017-03-30 08:26:05
ActionScript3 source code
/**
* Copyright hemingway ( http://wonderfl.net/user/hemingway )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zhvK
*/
package {
import flash.display.*;
import flash.system.*;
import flash.events.*;
import flash.geom.*;
public class Main extends Sprite
{
[SWF(frameRate = 60, width = 461, height = 461)]
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
}
public function _init() :void
{
graphics.clear();
graphics.lineStyle(1, 0, 0.9);
graphics.drawRect(0, 0, 464, 464);
}
public function addedToStage($e:Event) :void
{
removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
_init();
NodeBuffer.buildContext(this);
}
}
}
import flash.display.*;
import flash.system.*;
import flash.events.*;
import flash.geom.*;
class NodeBuffer
{
public static function buildContext($context:Object) :void
{
$context.addChild(new Node(225, 225, 25));
}
}
class NodeDialog extends Sprite
{
protected var _x :Number;
protected var _y :Number;
protected var _width :Number;
protected var _height :Number;
protected var _color :Number;
protected var _alpha :Number;
public function NodeDialog()
{
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
_x = _y = _width = _height = _color = _alpha = 0;
}
public function _init() :void
{
graphics.clear();
graphics.lineStyle(1, 0, 0);
graphics.beginFill(color, alpha);
graphics.drawRect(x, y, width, height);
graphics.moveTo(225, (225 + 25));
graphics.lineTo(x, ((y + height)));
graphics.lineTo((x + width), (y + height));
graphics.lineTo((225 + 25) + 1, (225 + 25));
graphics.endFill();
}
public function addedToStage($e:Event) :void
{
removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
_init();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function expandNode() :void
{
alpha = 1;
color = 0xA3A3A3;
x = y = 225;
width = height = 25;
}
public function onEnterFrame($e:Event) :void
{
if (alpha > 0)
{
if (y > 140)
{x--; y-=4; width+=2; height+=2;}
}
}
public function get color() :Number
{ return _color }
public override function get x() :Number
{ return _x }
public override function get y() :Number
{ return _y }
public override function get width() :Number
{ return _width }
public override function get height() :Number
{ return _height }
public override function get alpha() :Number
{ return _alpha }
public function set color($:Number) :void
{ _color = $; _init(); }
public override function set x($:Number) :void
{ _x = $; _init(); }
public override function set y($:Number) :void
{ _y = $; _init(); }
public override function set width($:Number) :void
{ _width = $; _init(); }
public override function set height($:Number) :void
{ _height = $; _init(); }
public override function set alpha($:Number) :void
{ _alpha = $; _init(); }
}
class Node extends Sprite
{
protected var _x :Number;
protected var _y :Number;
protected var _width :Number;
protected var _height :Number;
protected var _color :Number;
protected var _alpha :Number;
private var nodeDialog :NodeDialog;
public function Node($x:Number, $y:Number, $scale:Number)
{
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
_x = $x;
_y = $y;
_width = _height = $scale;
_color = 0xA3A3A3;
_alpha = 1;
nodeDialog = new NodeDialog();
}
protected function _init() :void
{
graphics.clear ();
graphics.lineStyle (1, 0, 0);
graphics.beginFill (type, alpha);
graphics.drawRect (x, y, scale, scale);
graphics.endFill ();
}
private function addedToStage($e:Event) :void
{
removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
_init();
addChild(nodeDialog);
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
public function onMouseOver($e:MouseEvent) :void
{
alpha = 0.5;
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
}
public function onMouseOut($e:MouseEvent) :void
{
removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
alpha = 1;
}
public function onMouseDown($e:MouseEvent) :void
{
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
public function onMouseUp($e:MouseEvent) :void
{
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
nodeDialog.expandNode();
}
public function get type() :Number
{ return _color }
public function get scale() :Number
{ return _width }
public function set type($:Number) :void
{ _color = $; _init(); }
public function set scale($:Number) :void
{ _width = _height = $; _init(); }
public override function get x() :Number
{ return _x }
public override function get y() :Number
{ return _y }
public override function get alpha() :Number
{ return _alpha }
public override function set x($:Number) :void
{ _x = $; _init(); }
public override function set y($:Number) :void
{ _y = $; _init(); }
public override function set alpha($:Number) :void
{ _alpha = $; _init(); }
}