スライダのスイッチ
音量などのスイッチの仕組みで、画像のズームをさせたかったので、おためしで作りました。
というより、今まで作ったことありませんでした。
今回は単純にAS1.0です。
はじめにスライダの動作座標を規定して、次にstartDragとstopDrag。
そして、Drag中に値をとるため、Listenerを設定します。
//ActionScript//////////////////////////////////////////////////////////////////
//ここに初期設定を入れる
略
function panmove () {
xWidth = base_mc._width - pan_mc._width;
xMin = base_mc._x;
xMax = base_mc._x+xWidth;
pan = 略
}
this.pan_mc.onPress = function () {
pan_mc.startDrag(true,xMin,pan_mc._y,xMax, pan_mc._y);
drag = true;
}
this.pan_mc.onRelease = function () {
pan_mc.stopDrag();
drag = false;
}
this.pan_mc.onReleaseOutside = function () {
pan_mc.stopDrag();
drag = false;
}
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
if (drag == true) {
panmove ();
}
};
Mouse.addListener(mouseListener);
サンプル(別ウィンドウ)
というより、今まで作ったことありませんでした。
今回は単純にAS1.0です。
はじめにスライダの動作座標を規定して、次にstartDragとstopDrag。
そして、Drag中に値をとるため、Listenerを設定します。
//ActionScript//////////////////////////////////////////////////////////////////
//ここに初期設定を入れる
略
function panmove () {
xWidth = base_mc._width - pan_mc._width;
xMin = base_mc._x;
xMax = base_mc._x+xWidth;
pan = 略
}
this.pan_mc.onPress = function () {
pan_mc.startDrag(true,xMin,pan_mc._y,xMax, pan_mc._y);
drag = true;
}
this.pan_mc.onRelease = function () {
pan_mc.stopDrag();
drag = false;
}
this.pan_mc.onReleaseOutside = function () {
pan_mc.stopDrag();
drag = false;
}
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
if (drag == true) {
panmove ();
}
};
Mouse.addListener(mouseListener);
サンプル(別ウィンドウ)