pont vonal

az hogy distance between 2 movieclip az ok. az hogy distance pont és vonal között az így van.

esetünkben így : (mozgasd a pontokat)

<img src=\"/wp-content/plugins/flqt/needplugin.gif\" height="31" alt="placeholder for flash movie" />

eze:

p2p=function(a,b){
	var x=a._x-b._x
	var y=a._y-b._y
	return Math.sqrt(x*x+y*y)
}

p2l=function(a,b,c){
	var bax=b._x-a._x
	var bay=b._y-a._y
	var cay=c._y-a._y
	var cax=c._x-a._x

	a.clear()
	a.lineStyle(0,0x769DB5,20)
	a.moveTo(0,0)
	a.lineTo(bax,bay)

	var q=(cax*bax+cay*bay)/(bax*bax+bay*bay)
	if (q<0){q=0} else if (q>1) q=1
	return p2p(c,{_x:((1-q)*a._x+q*b._x),_y:((1-q)*a._y+q*b._y)})
}

_root.onEnterFrame=function(){out=p2l(a,b,c)}

setDrag=function(d){
	d.onPress=function(){
		this.onMouseMove=function() {
			this._x=_xmouse
			this._y=_ymouse
			updateAfterEvent()
			_root.onEnterFrame()
		}
	}
	d.onRelease=this.onReleaseOutside=function(){delete this.onMouseMove}
}

setDrag(a)
setDrag(b)
setDrag(c)

</code>

az fla meg itt van.