Re: [Flashcoders] Maintain position on rotation

2008-06-19 Thread jonathan howe
Eric,

In your comment you mentioned localToGlobal wasn't updating. Just in case:
one misttep that I made when first working with AS3 was that localToGlobal
no longer modifies the point you pass it. You have to evaluate the return
value i.e.

changedPoint = someDisplayObject.localToGlobal(originalPoint);

changedPoint not originalPoint.

-jonathan


On Wed, Jun 18, 2008 at 8:34 PM, eric e. dolecki [EMAIL PROTECTED] wrote:

 Hey guys,

 Before I saw these response posts, I took a slightly different angle on
 things. When I create my limbs, I am actually adding another limb to a
 joint
 sprite on the end of the main limb. That way it simply moves with the upper
 limb, and can still rotate freely on its own, using some rotational rules.
 It avoids a bunch of math and allows the nesting to simply take care of
 some
 of it.

 When I tried points and localToGlobal, it still gave me weird results,
 making me take the route above.

 Thanks for the responses, it's why this list is the best in the world.

 - e.

 On Wed, Jun 18, 2008 at 2:16 PM, Jon Bradley [EMAIL PROTECTED]
 wrote:

 
  On Jun 18, 2008, at 1:27 PM, eric e. dolecki wrote:
 
   While rotating, I want to place another MC's x,y (each frame) on that
  rotating MC. However the x,y never updates. I tried localToGlobal, but
  that
  doesn't seem to change either during the rotation. Can this be easily
  done?
 
 
 
  Give something like this a shot. Note that this is completely untested
  because I wrote it right here ... this is the general idea though.
 
  var m:Matrix = mainMC.transform.matrix;
  var pt:Point = new Point( mainMC.theChild.x, mainMC.theChild.y);
 
  var position:Point = m.transformPoint(pt);
 
  // You might need to add in the tx,ty offsets
  var matchMoveClipX:Number = position.x + m.tx;
  var matchMoveClipY:Number = position.y + m.ty;
 
  That assumes, of course, that you're applying your transformations using
  matrices.
 
  If you use dot notation on the properties (rotate, scale, x y), I'm not
  100% certain that those properties are updated in the transformation
 matrix
  of the object.
 
  good luck.
 
  jon
 
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Maintain position on rotation

2008-06-18 Thread eric e. dolecki
AS3. I have a MC I am rotating, and inside the MC I have a Sprite (affixed
to the bottom of the MC).

While rotating, I want to place another MC's x,y (each frame) on that
rotating MC. However the x,y never updates. I tried localToGlobal, but that
doesn't seem to change either during the rotation. Can this be easily done?
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Maintain position on rotation

2008-06-18 Thread Rob Romanek

Hi Eric,

Try out this code, should do the trick and show that localToGlobal  
does work

Run it once as is, then uncomment the rotation and see the results.

hth,

Rob



var sprite1:Sprite = new Sprite();
sprite1.graphics.beginFill(0x00ff00);
sprite1.graphics.drawRect(0,0,100,100);
sprite1.graphics.endFill();

var sprite2:Sprite = new Sprite();
sprite2.graphics.beginFill(0xff);
sprite2.graphics.drawRect(0,0,10,10);
sprite2.graphics.endFill();

sprite1.addChild(sprite2);
sprite2.x = 90;
sprite2.y = 90;

addChild(sprite1);
sprite1.x=100;
sprite1.y=100;

//sprite1.rotation = 45;

trace(sprite1.localToGlobal(new Point(sprite2.x, sprite2.y)));


On 18-Jun-08, at 1:27 PM, eric e. dolecki wrote:

AS3. I have a MC I am rotating, and inside the MC I have a Sprite  
(affixed

to the bottom of the MC).

While rotating, I want to place another MC's x,y (each frame) on that
rotating MC. However the x,y never updates. I tried localToGlobal,  
but that
doesn't seem to change either during the rotation. Can this be  
easily done?

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Maintain position on rotation

2008-06-18 Thread Rich Shupe
Theoretically, I'm not sure why not. Can you describe how/where they should
overlap or post some code?


On 6/18/08 1:27 PM, eric e. dolecki  wrote:

 AS3. I have a MC I am rotating, and inside the MC I have a Sprite (affixed
 to the bottom of the MC).
 
 While rotating, I want to place another MC's x,y (each frame) on that
 rotating MC. However the x,y never updates. I tried localToGlobal, but that
 doesn't seem to change either during the rotation. Can this be easily done?

Rich
http://www.LearningActionScript3.com


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Maintain position on rotation

2008-06-18 Thread Jon Bradley


On Jun 18, 2008, at 1:27 PM, eric e. dolecki wrote:


While rotating, I want to place another MC's x,y (each frame) on that
rotating MC. However the x,y never updates. I tried localToGlobal,  
but that
doesn't seem to change either during the rotation. Can this be  
easily done?



Give something like this a shot. Note that this is completely  
untested because I wrote it right here ... this is the general idea  
though.


var m:Matrix = mainMC.transform.matrix;
var pt:Point = new Point( mainMC.theChild.x, mainMC.theChild.y);

var position:Point = m.transformPoint(pt);

// You might need to add in the tx,ty offsets
var matchMoveClipX:Number = position.x + m.tx;
var matchMoveClipY:Number = position.y + m.ty;

That assumes, of course, that you're applying your transformations  
using matrices.


If you use dot notation on the properties (rotate, scale, x y), I'm  
not 100% certain that those properties are updated in the  
transformation matrix of the object.


good luck.

jon
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Maintain position on rotation

2008-06-18 Thread eric e. dolecki
Hey guys,

Before I saw these response posts, I took a slightly different angle on
things. When I create my limbs, I am actually adding another limb to a joint
sprite on the end of the main limb. That way it simply moves with the upper
limb, and can still rotate freely on its own, using some rotational rules.
It avoids a bunch of math and allows the nesting to simply take care of some
of it.

When I tried points and localToGlobal, it still gave me weird results,
making me take the route above.

Thanks for the responses, it's why this list is the best in the world.

- e.

On Wed, Jun 18, 2008 at 2:16 PM, Jon Bradley [EMAIL PROTECTED]
wrote:


 On Jun 18, 2008, at 1:27 PM, eric e. dolecki wrote:

  While rotating, I want to place another MC's x,y (each frame) on that
 rotating MC. However the x,y never updates. I tried localToGlobal, but
 that
 doesn't seem to change either during the rotation. Can this be easily
 done?



 Give something like this a shot. Note that this is completely untested
 because I wrote it right here ... this is the general idea though.

 var m:Matrix = mainMC.transform.matrix;
 var pt:Point = new Point( mainMC.theChild.x, mainMC.theChild.y);

 var position:Point = m.transformPoint(pt);

 // You might need to add in the tx,ty offsets
 var matchMoveClipX:Number = position.x + m.tx;
 var matchMoveClipY:Number = position.y + m.ty;

 That assumes, of course, that you're applying your transformations using
 matrices.

 If you use dot notation on the properties (rotate, scale, x y), I'm not
 100% certain that those properties are updated in the transformation matrix
 of the object.

 good luck.

 jon

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders