Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-29-2010, 02:47 PM   #1
exe89
Registered User
 
Join Date: Jan 2010
Posts: 2
Default Two draggable object problem

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?
exe89 is offline   Reply With Quote
Old 01-31-2010, 12:01 AM   #2
exe89
Registered User
 
Join Date: Jan 2010
Posts: 2
Default

Here is my code: http://www.filedropper.com/camera_4

I realized it just might be that I am overlapping 2 Movie Objects. Now my question is... can anybody help me to make such a program (move camera in hbar on x-axis) and hbar in y-axis?
exe89 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:46 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.