Got it,

 

First of all, the “example code” below that I sent earlier was an idea of what I wanted to accomplish, but didn’t actually work because as far as I know, one can’t just bind to the x and y coordinates of any UIComponent. Binding to the coordinates would mean that events are constantly being dispatched for every movement of every UIComponent. I don’t think this is the case, (Is it?) it seems like it would be way too much traffic for an application to be efficient.

 

The solution I am satisfied with is to use the granularity of the mouse move event to sync the positions of two Sprites.

 

       private function mouseDownHandler(event:MouseEvent):void {

            var sprite:Sprite = Sprite(event.target);

            sprite.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

            sprite.startDrag();

        }

 

        private function mouseMoveHandler(event:MouseEvent):void {

            followerSprite.x=leaderSprite.x+150;

            followerSprite.y=leaderSprite.y+150;

            event.updateAfterEvent();

        }

 

This syncs position pretty well. If you drag a sprite real quick, it looses track of it for a brief period of time so a more smooth tracking could be accomplished with the previous setInterval() method.

 

Is there a better way to do this which would detect a pixel-by-pixel movement of a sprite?

 

Thanks,
Evan

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Michael Schmalle
Sent: Monday, November 06, 2006 4:51 PM
To: [email protected]
Subject: Re: [flexcoders] Realtime Panel position sync?

 

Hi Even,

I think what is happening is you are seeing the startDrag() method interacting with the player's x and y properties of the DisplayObject.

Whereas the UIComponent is bound by xChanged event, the player does not dispatch an event. The only reason you are even getting the panel to move with the mouseUp event is because the LayoutManager validated the parent.

The methods startDrag() and stopDrag() are 'really' meant for non UIComponents. Yes, yes, you can laugh at me but, seriously if I remember correctly, they are not piped into the framework in the way you would expect the methods to work.

I would say, go the distance and write a method using mouse events and mouseMove, using the systemManager, see the Panel source code.

The saying in life, 'You get what you pay for' applies nicely right here.

Peace, Mike

On 11/6/06, Evan Gifford <[EMAIL PROTECTED]ams.com> wrote:

Hey guys,

 

I'd like to sync the positions of two …. Panels, let's say, while one of the two is being actively dragged.

 

 

Here is the ghetto way of doing it (or is it?)

 

Private syncInterval:Object = setInterval(syncWindowPosition,20);

 

Private function syncWindowPosition():void{

 

            panelTwo.x=panelOne.x + 250;

            panelTwo.y=panelOne.y + 250;

}

 

As you can guess, this simulates a real-time position sync so that, as I drag one window the other one follows suite, offset by 250px.

 

But that's just wrong (or is it?)

 

What I'd like to do is something like this.

 

<mx:Panel x="456" y="145" width="250" height="200" layout="absolute" id=" panelOne" mouseUp=" panelOne.stopDrag()" mouseDown="one.startDrag()">

<mx:Panel x="{panelOne.x + 250}" y="{panelOne.y + 250}"  width="250" height="200" layout="absolute" id=" panelTwo">

 

This works on creationComplete, but there is no redraw done after that or while I drag the 1st window.

 

 

What am I missing?

 

Thanks!

 

 

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.28/518 - Release Date: 11/4/2006




--
Teoti Graphix
http://www.teotigraphix.com

Blog - Flex2Components
http://www.flex2components.com

You can find more by solving the problem then by 'asking the question'.

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.29/520 - Release Date: 11/6/2006


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.29/520 - Release Date: 11/6/2006

Reply via email to