A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: User input - Please help!

  1. #1
    Junior Member
    Join Date
    Mar 2004
    Location
    uk
    Posts
    25

    User input - Please help!

    Hi,

    i have created a flash movie that shows the layout of a computer room. I want the user to be able to draw lines between these computers, hence showing they are connected.
    How can i allow the user to to draw various lines between the computers and choose the colour of the line they want.


    Thanks

  2. #2
    Between Flash & Flashkit timothye's Avatar
    Join Date
    Dec 2003
    Location
    Sweden
    Posts
    1,666
    you can draw with this .
    Code:
    _root.onMouseDown = function() {
    	_root.lineStyle(5, 0xFFCC00, 100);
    	_root.moveTo(_root._xmouse, _root._ymouse);
    	isDrawing = true;
    };
    _root.onMouseMove = function() {
    	if (isDrawing == true) {
    		_root.lineTo(_root._xmouse, _root._ymouse);
    		updateAfterEvent();
    	}
    };
    _root.onMouseUp = function() {
    	isDrawing = false;
    };
    cheers
    I want to learn .
    wannabe flasher [ Actionscript 2.0 ]

  3. #3
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    Timothye's method will work, but if you don't draw a perfectly straight line, will leave scraps lying around that you might not want.

    If that's a problem for your application, try creating a new movie clip, say "lineClip" + i, for each line, then calling all the drawing commands on lineClip. Put lineClip.clear() at the start.

    e.g.,

    code:

    var counter = 0;
    aComputer.onPress = function() {
    counter++;
    var startX = _root._xmouse;
    var startY = _root._ymouse;
    var lc = _root.createEmptyMovieClip("lineClip" + counter, counter);
    lc.onMouseMove = function() {
    this.clear();
    this.lineStyle(1, 0);
    this.moveTo(startX, startY);
    this.lineTo(lc._xmouse, lc._ymouse);
    }
    lc.onMouseUp = function() {
    delete this.onMouseMove;
    delete this.onMouseUp;
    }
    }


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