I have a draggable (x-axis) camera attached to a horizontal bar. Then I attach this horizontal bar, which too is draggable (y-axis), to 2 vertical bars.
When I write this code for the Hbar (or "panel1"), the y-axis works perfectly!
ActionScript Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
var panel1Dist:int = 0;
panel1.addEventListener(MouseEvent.MOUSE_DOWN, panel1DownHandler);
panel1.addEventListener(MouseEvent.MOUSE_UP, panel1UpHandler);
panel1.addEventListener(MouseEvent.MOUSE_OUT, panel1OutHandler);
// Camera 1
function panel1DownHandler(evt:MouseEvent):void{
trace('trans - panel')
var object = evt.target;
var r:Rectangle = new Rectangle(-2.2,
-20,
0,
270);
object.startDrag(false, r);
}
function panel1UpHandler(evt:MouseEvent):void{
var obj = evt.target;
obj.stopDrag();
panel1Dist = panel1.x;
}
function panel1OutHandler(evt:MouseEvent):void{
var obj = evt.target;
obj.stopDrag();
panel1Dist = panel1.x;
}
However, when I go inside HBar's symbol and type this (below), the camera does not move on the x-axis! If I comment out panel1's event handlers the camera moves correctly on the x-axis.
ActionScript Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
var camera1Dist:int = 0;
camera1.addEventListener(MouseEvent.MOUSE_DOWN, camera1DownHandler);
camera1.addEventListener(MouseEvent.MOUSE_UP, camera1UpHandler);
camera1.addEventListener(MouseEvent.MOUSE_OUT, camera1OutHandler);
// Camera 1
function camera1DownHandler(evt:MouseEvent):void{
trace('trans')
var object = evt.target;
var r:Rectangle = new Rectangle(0,
0,
800 - object.width,
0);
object.startDrag(false, r);
}
function camera1UpHandler(evt:MouseEvent):void{
var obj = evt.target;
obj.stopDrag();
camera1Dist = camera1.x;
}
function camera1OutHandler(evt:MouseEvent):void{
var obj = evt.target;
obj.stopDrag();
camera1Dist = camera1.x;
}
// Panel 1
So my dilemma is EITHER I can move the hbar on the y-axis OR I can move the camera along the x-axis. Can anybody help me out?