flash on 2009-10-16
/**
* Copyright incl_ ( http://wonderfl.net/user/incl_ )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/elEc
*/
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
public var a: Sprite;
public var m: Sprite;
public var b: Sprite;
public function FlashTest() {
a = new Sprite();
a.graphics.beginFill(0, 0);
a.graphics.drawRect(0, 0, 200, 50);
a.x = a.y = 100;
addChild(a);
m = new Sprite();
m.graphics.beginFill(0);
m.graphics.moveTo(0, 50);
m.graphics.lineTo(200, 0);
m.graphics.lineTo(200, 50);
m.alpha = 0.5;
a.addChild(m);
b = new Sprite();
b.graphics.beginFill(0x0099ff);
b.graphics.drawRect(0, 0, 200, 50);
b.alpha = 0.5;
a.addChild(b);
b.mask = m;
a.addEventListener(MouseEvent.MOUSE_OVER, function(e: MouseEvent): void {
b.alpha = 1;
});
a.addEventListener(MouseEvent.MOUSE_OUT, function(e: MouseEvent): void {
b.alpha = 0.5;
});
a.addEventListener(MouseEvent.MOUSE_DOWN, function(e: MouseEvent): void {
b.x = e.stageX - 100 - b.width;
a.addEventListener(MouseEvent.MOUSE_MOVE, volume);
});
a.addEventListener(MouseEvent.MOUSE_UP, function(e: MouseEvent): void {
b.alpha = 0.5;
a.removeEventListener(MouseEvent.MOUSE_MOVE, volume);
});
}
public function volume(e: MouseEvent): void {
b.x = e.stageX - 100 - b.width;
}
}
}