✔ 最佳答案
板大好
fla 內的元件配置,很難解說,所以我將 fla 檔放在免費空間,如下:
http://www.myupload.dk/showfile/1M05Shrc_.fla
檔案名為 dragSlider.fla
請按下右下方 Download now
如果有問題,請來信
[email protected]
底下是,主影格的語法:
var frameNumber:Number = 0;
slider1.x = line.x;
slider1.addEventListener(MouseEvent.MOUSE_DOWN, DragObject);
stage.addEventListener(MouseEvent.MOUSE_UP, DropObject);
slider1.buttonMode = true;
function DragObject(e:MouseEvent):void
{
slider1.addEventListener(Event.ENTER_FRAME, movement);
}
function DropObject(e:MouseEvent):void
{
slider1.removeEventListener(Event.ENTER_FRAME, movement);
}
function movement(e:Event):void
{
if (mouseX >= line.x && mouseX <= line.x + line.width)
{
frameNumber = Math.ceil((slider1.x-line.x)/line.width*10);//10是myMC全部的影格數
slider1.x = mouseX;
myMC.gotoAndStop(frameNumber);
}
if (slider1.x < slider1.x)
{
slider1.x = slider1.x;
}
if (slider1.x > line.x + line.width)
{
slider1.x = line.x + line.width;
}
}