dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: dynamic lines that follow points

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    4

    dynamic lines that follow points

    Hi all, I'm a noob and been looking for answers all day. I am trying to create a mindmap where the user can drag points about the screen, and the lines connected them to them follow. I have gotten as far as drawing the line via actionscript, and drag+drop the points (defined as movie clips on stage). This is the existing script - I don't know how to get the lines to follow the points. Something to do with ENTER_FRAME or updateAfterEvent? I have seen examples using onEnterFrame and createEmptyMovieClip and one with setInterval, but they are in previous Actionscripts. I don't know how to translate them into AS3.. PLEASE HELP!!

    var line:MovieClip = new MovieClip();
    line.graphics.lineStyle(1,1);
    line.graphics.moveTo(ptOne.x,ptOne.y);
    line.graphics.lineTo(ptTwo.x,ptTwo.y);
    addChild(line);

    ptOne.addEventListener(MouseEvent.MOUSE_DOWN, Drag1);

    function Drag1(event:MouseEvent):void
    {
    ptOne.startDrag();
    }

    stage.addEventListener(MouseEvent.MOUSE_UP, Release1);

    function Release1(event:MouseEvent):void
    {
    ptOne.stopDrag();
    }

    ptTwo.addEventListener(MouseEvent.MOUSE_DOWN, Drag2);

    function Drag2(event:MouseEvent):void
    {
    ptTwo.startDrag();
    }

    stage.addEventListener(MouseEvent.MOUSE_UP, Release2);

    function Release2(event:MouseEvent):void
    {
    ptTwo.stopDrag();
    }

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    PHP Code:
    var line:MovieClip = new MovieClip();
    addChild(line);

    draw(null);

    ptOne.addEventListener(MouseEvent.MOUSE_DOWNDrag1);

    function 
    Drag1(event:MouseEvent):void {
        
    ptOne.startDrag();
        
    stage.addEventListener(Event.ENTER_FRAMEdraw);
    }

    stage.addEventListener(MouseEvent.MOUSE_UPRelease1);

    function 
    Release1(event:MouseEvent):void {
        
    ptOne.stopDrag();
        
    stage.removeEventListener(Event.ENTER_FRAMEdraw);
    }

    ptTwo.addEventListener(MouseEvent.MOUSE_DOWNDrag2);

    function 
    Drag2(event:MouseEvent):void {
        
    ptTwo.startDrag();
        
    stage.addEventListener(Event.ENTER_FRAMEdraw);
    }

    stage.addEventListener(MouseEvent.MOUSE_UPRelease2);

    function 
    Release2(event:MouseEvent):void {
        
    ptTwo.stopDrag();
        
    stage.removeEventListener(Event.ENTER_FRAMEdraw);
    }

    function 
    draw(event:Event):void{
        
    line.graphics.clear();
        
    line.graphics.lineStyle(1,1);
        
    line.graphics.moveTo(ptOne.x,ptOne.y);
        
    line.graphics.lineTo(ptTwo.x,ptTwo.y);


  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    wow thanks moagrius! it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center