Slider

Code Actionscript 2.0

Instance action

on (press) {
mousepressed = 1;
}
on (release, releaseOutside) {
mousepressed = 0;
}
onClipEvent (enterFrame) {
if (mousepressed == 1) {
this._y = _root._ymouse;
output = (_root._ymouse) / 4;
_parent.square1._alpha = output;
_parent.square2._alpha = 100 - output;
}
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); stage.addEventListener(MouseEvent.MOUSE_UP, releaseOutside); slider.addEventListener(MouseEvent.MOUSE_DOWN, press); slider.addEventListener(MouseEvent.MOUSE_UP, release); var mousepressed = 0; function press(e:MouseEvent) { mousepressed = 1; } function release(e:MouseEvent){ mousepressed = 0; } function releaseOutside(e:MouseEvent) { mousepressed = 0; } function enterFrame(event:Event) { if (mousepressed == 1) { slider.y = mouseY; var output = (mouseY) / 400; box1.alpha = output; box2.alpha = 1 - output; } }

Description

The value output is continuously changed by moving the slider. Here, the variable output is used to change the opacity alpha of the two squares.

related to: Scrollbox, Mouse position

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share