I have a feeling I might be going about this all wrong. I have 3 objects (mask_cat, mask_dog, mask_sea_monster)on the stage and I want the user to be able to move them independently with the ol’ click and drag. This is what I have:
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class maskGuys extends MovieClip {
private var bg1:Sprite;
private var mask_cat:MovieClip;
private var mask_dog:MovieClip;
private var mask_sea_monster:MovieClip;
public function maskGuys() {
init();
}
private function init():void {
var bg1:Background1 = new Background1();
addChild(bg1);
bg1.x = 125;
bg1.y = 40;
mask_cat = new MaskCat();
addChild(mask_cat);
mask_cat.x = 50;
mask_cat.y = 30;
mask_cat.addEventListener(MouseEvent.MOUSE_DOWN, onClickDown);
mask_cat.addEventListener(MouseEvent.CLICK, clickswap);
mask_dog = new MaskDog();
addChild(mask_dog);
mask_dog.x = 10;
mask_dog.y = 175;
mask_dog.addEventListener(MouseEvent.MOUSE_DOWN, onClickDown);
mask_dog.addEventListener(MouseEvent.CLICK, clickswap);
mask_sea_monster = new MaskSeaMonster();
addChild(mask_sea_monster);
mask_sea_monster.x = 450;
mask_sea_monster.y = 100;
mask_sea_monster.addEventListener(MouseEvent.MOUSE_DOWN, onClickDown);
mask_sea_monster.addEventListener(MouseEvent.CLICK, clickswap);
}
function onClickDown(event:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_UP, onClickUp);
mask_cat.startDrag(false, new Rectangle(10, 10, 500, 200));
mask_dog.startDrag(false, new Rectangle(10, 10, 500, 200));
mask_sea_monster.startDrag(false, new Rectangle(10, 10, 500, 200));
}
function onClickUp(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, onClickUp);
mask_cat.stopDrag();
mask_dog.stopDrag();
mask_sea_monster.stopDrag();
}
function clickswap(event:MouseEvent) {
setChildIndex(MovieClip(event.currentTarget),numChildren-1);
}
}
}
So far only the , sea_monster moves. The odd thing is the sea_monster moves when I click on the dog or the cat also, but not if I click anywhere else.
Any ideas?