flash on 2014-1-2

by GreekFellows
♥0 | Line 46 | Modified 2014-01-02 23:51:29 | MIT License
play

ActionScript3 source code

/**
 * Copyright GreekFellows ( http://wonderfl.net/user/GreekFellows )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fdYh
 */

package {
    import flash.geom.Point;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    public class Connection extends Sprite {
        public var lines:Array;
        public var connectees:Array;
        public function Connection() {
            var s:Sprite = new Sprite();
            s.graphics.beginFill(0xffffff, 1);
            s.graphics.drawRect(0, 0, 465, 465);
            s.graphics.endFill();
            this.addChild(s);
            this.addEventListener(MouseEvent.CLICK, addConnectee);
        }
        
        public function addConnectee(me:MouseEvent):void {
            var c:connectee = new connectee(new Point(mouseX, mouseY));
            connectees.push(c);
            c.draw(this.getChildAt(0).graphics);
        }
    }
}

import flash.display.Graphics;
import flash.geom.Point;

class line {
    public var p0:Point;
    public var p1:Point;
    
    public function line(cp0:Point, cp1:Point):void {
        this.p0 = cp0;
        this.p1 = cp1;
    }
}

class connectee {
    public var pos:Point;
    public var size:Point;
    
    public function connectee(cpos:Point):void {
        this.pos = cpos;
        this.size = new Point(20, 20);
    }
    
    public function draw(g:Graphics):void {
        g.beginFill(0xffffff, 1);
        g.lineStyle(1, 0, 1);
        g.drawRect(pos.x, pos.y, size.x, size.y);
        g.endFill();
    }
}