2010-07-16 3 views
0

사용자가 타임 라인에서 시간 범위를 선택할 수있는 메커니즘을 만드는 데 어려움을 겪고 있습니다. 기본적으로 나는 그들이 수평으로 클릭하고 드래그 할 수 있고, 그 이벤트의 시작과 끝 위치를 검색 할 수 있기를 원한다.순전히 액션 스크립트에서 끌기 막대 만들기

특히 이벤트가 화면 가장자리에서 벗어난 경우를 포함해야합니다 (끝 위치가 화면의 가장자리에 잘 맞았음에도 불구하고).

이 모든 작업을 수행하면서 이벤트 시작부터 마우스의 현재 위치까지가는 상자를 그릴 수 있기 때문에 선택되는 영역이 분명합니다.

답변

3

기본적으로, 나는 당신이 뭔가를 끌고있는 것 같지 않습니다. 언론, 이동 및 석방의 순서가 있습니다. 당신은 무언가를 클릭해야 할 것입니다, 나는 당신이 타임 라인 자체의 언론 사건을 고려할 수 있다고 확신합니다. 같은 것이있을거야 뭔가 : 선택 그래픽 자체에 대한

timeline.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 
timeline.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
// the next line just considers that leaving the object surface is the same as depressing the mouse button 
timeline.addEventListener(MouseEvent.MOUSE_OUT, onMouseUp); 

function onMouseDown(evt:MouseEvent):void { 
    // add the event listener for the mouse move action 
    timeline.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 
    // create the movie clip for the box 
    // you get the mouse coordinates from evt.localX and evt.localY (relative to the origin of the timeline movieclip) or evt.stageX and evt.stageY (as global values) 
} 

function onMouseMove(evt:MouseEvent):void { 
    // adjust the selection width and height 
    // you get the mouse coordinates from evt.localX and evt.localY (relative to the origin of the timeline movieclip) or evt.stageX and evt.stageY (as global values) 
} 

function onMouseUp(evt:MouseEvent):void { 
    // remove the event listener for the mouse move, that means that the function onMouseMove will no longer be called 
    timeline.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 
    // brush up and send the final coordinates of the selection to the next function 
} 

, 당신은 라이브러리에서 동영상 클립의 인스턴스를 사용할 수 있습니다, 또는 당신은 단순히 빈 무비 클립을 만들 수는 반투명하고 그릴 수 그 안에있는 사각형 :

var selection:MovieClip = new MovieClip(); 
selection.alpha = 0.5; 
selection.graphics.beginFill(0x000000); 
selection.graphics.drawRect(x,y,width,height); 
selection.graphics.endFill(); 
this.addChild(selection); 
관련 문제