0
votes

I want to know how to position a movieClip(my_mcB) nested inside a resized movieClip(my_mcA);

my_mcA is originally 1080 wide.

my_mcA is set to resize according to the stage width and scale proportionally to the device width it is loaded in. Here is the resize code that works fine:

my_mcA.width = stage.stageWidth;
my_mcA.scaleY = my_mcA.scaleX;

I am testing on a stage that is 500 wide. my_mcA rescales fine. However, if I try to reposition my_mcB that is inside my_mcA it seems to use the old values of the 1080. If I used this code:

my_myA.my_mcB.x = stage.stageWidth; // NEED HELP WITH THIS LINE

my_mcB should be off the stage but it shows up half way in the middle of the screen.

In my project I will be using a screen swipe and many tweens so I need to get formula to place the objects on screen in the right places as well as the length of the movement in the tween etc... How can I correctly position a nested movieClip in a resized movieClip?

1

1 Answers

1
votes

Try

my_mcA.my_mcB.x = 1080;

If you scale the outer container (my_mcA) to fit the screen, it shouldn't affect the inner coordinate system of my_mcB. 500 width would be roughly the middle of 1080 and it sounds like you saw that.

EDIT: You asked how to get the original width of the inner display object. You get it by accessing the width property of the inner movieclip. Here an example of how the inner display object width reacts on scaling the outer display object by using scaling or the width property:

trace("unscaled my_mcA.my_mcB.width="+mcA.my_mcB.width);
my_mcA.scaleX=0.5;
my_mcA.scaleY=0.5;
trace("scaleX scaled my_mcA.my_mcB.width="+my_mcA.my_mcB.width);
my_mcA.width=250;
my_mcA.scaleY=my_mcA.scaleX;
trace("width scaled my_mcA.my_mcB.width="+my_mcA.my_mcB.width);

This should be the output of the script:

unscaled my_mcA.my_mcB.width=550
scaleX scaled my_mcA.my_mcB.width=550
width scaled my_mcA.my_mcB.width=550

EDIT 2: If you want the actually displayed width, you need to multiply the width property of the inner display object with the x scaling (scaleX) of the outer display object:

trace("display width="+(my_mcA.my_mbB.width*my_mcA.scaleX));

This is just an simple example. With multiple nested movieclips you'd need to apply the scaling factors of the whole nesting chain.