特定レイヤー内InteractiveObjectのマウスイベントを無効化
/**
* Copyright naoto5959 ( http://wonderfl.net/user/naoto5959 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qGTj
*/
package {
import flash.display.*;
import flash.net.*;
import flash.events.*;
public class FlashTest extends Sprite {
private const SAMPLE_IMAGE1:String = "http://assets.wonderfl.net/images/related_images"
+ "/e/ee/eef0/eef05cad0bd043e43f073ac0aa17d62a94b1925d";
private const SAMPLE_IMAGE2:String = "http://assets.wonderfl.net/images/related_images"
+ "/f/ff/ff4b/ff4b1eeaba5edeb3dff3db15473e799470e3b646";
private const SAMPLE_IMAGE3:String = "http://assets.wonderfl.net/images/related_images"
+ "/9/97/973e/973e13e6cc342ec127fe971cbf3aff47de662f32";
private var _loader1:Loader;
private var _loaderContainer1:Sprite;
private var _loader2:Loader;
private var _loaderContainer2:Sprite;
private var _loader3:Loader;
public function FlashTest() {
// write as3 code here..
_loaderContainer1 = new Sprite();
_loaderContainer1.buttonMode = true;
_loaderContainer1.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown1);
_loaderContainer1.addEventListener(MouseEvent.MOUSE_UP, onMouseUp1);
addChild(_loaderContainer1);
_loader1 = new Loader();
_loader1.x = 465 / 2;
_loader1.y = 465 / 2;
_loader1.load(new URLRequest(SAMPLE_IMAGE1));
_loaderContainer1.addChild(_loader1);
_loader3 = new Loader();
_loader3.mouseEnabled = false;
_loader3.load(new URLRequest(SAMPLE_IMAGE3));
addChild(_loader3);
_loaderContainer2 = new Sprite();
_loaderContainer2.buttonMode = true;
_loaderContainer2.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown2);
_loaderContainer2.addEventListener(MouseEvent.MOUSE_UP, onMouseUp2);
addChild(_loaderContainer2);
_loader2 = new Loader();
_loader2.load(new URLRequest(SAMPLE_IMAGE2));
_loaderContainer2.addChild(_loader2);
stage.addEventListener(MouseEvent.MOUSE_DOWN, stage_onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
}
private function onMouseDown1(e:MouseEvent):void {
_loaderContainer1.startDrag();
_loader3.alpha = 0.6;
}
private function onMouseUp1(e:MouseEvent):void {
_loaderContainer1.stopDrag();
_loader3.alpha = 1.0;
}
private function onMouseDown2(e:MouseEvent):void {
_loaderContainer2.startDrag();
}
private function onMouseUp2(e:MouseEvent):void {
_loaderContainer2.stopDrag();
}
private function stage_onMouseDown(e:MouseEvent):void {
if (e.target != stage) {
return;
}
_loader3.alpha = 0.6;
}
private function stage_onMouseUp(e:MouseEvent):void {
if (e.target != stage) {
return;
}
loader3.alpha = 1.0;
}
}
}