views:

1562

answers:

4

I have a question of how to transform the parent movieclip and not the child movieclip...I have a movieclip holding an image loader and some handles as a movieclip. The handles movieclips are used to listen the mouse event to do such function scaling rotation and translation of the parent movieclip. The problem here when I scale or rotate the movieclip the handles also rotate and scale although I want it to follow the parent movieclip while the parent movieclip is rotating but I don't want handles to scale as well.

Is there a way of avoiding the handles from scaling.

Thank you

+2  A: 

If you're not stuck with that structure I would just rearrange things. For example, I would build it sort of like this:

- container
    - handles
    - image loader

This way you only have to worry about placing the handles in the correct places rather than dealing with scaling issues.

If you have to maintain the same structure, then you'll need to set the handles scale to be the inverse of the scale of the parent. For example, if the parent's scale was 2, you'd want the handle's scale to be 0.5. So all you have to do to calculate the handle's scale is to divide 1 by the parents scale.

Branden Hall
A: 
  1. Override the set height and set width functions in the parent MC (you could do scaleX and scaleY as well).
  2. In the overridden functions set the value, by calling super and then check the scaleX/scaleY
  3. set the scaleX (for width) or scaleY (for height) of the child MC to 1./scaleX (width) or 1./scaleY (height)

That was easy.

PiPeep
A: 

In an onEnterFrame handler or something like that set scaleX and scaleY to 1/(parent.scaleX) and 1/(parent.scaleY).

Ruud v A
+3  A: 

Try this:

inside_mc.addEventListener(Event.ENTER_FRAME, function(){
    inside_mc.scaleX = 1/inside_mc.parent.scaleX;
    inside_mc.scaleY = 1/inside_mc.parent.scaleY;
});
Makram Saleh
Terrific ! Using this I could set the width of my sub objects freely. It also let me use scale9grid fine on any child object this way:this.mychild.scaleX = 1/this.scaleX;this.mychild.width *= this.scaleX;Thanks !
XPac27