Jump to content
Search Community

dynamicProps - not x & y but name

Benjamin Waller test
Moderator Tag

Recommended Posts

Hello,

I have set up an example of a nice tween, thanks Greensock, that uses the x and y values like in the dynamicProps example on your site and it works fine. See my code below.

But I want to be able to reference my MC's position using its name instead so that I could change it's position on the stage but it will still tween to the correct spot wherever it is without having to change the x & y properties.

Could anyone help me to do this?

Ben.

em_Mc.addEventListener(MouseEvent.CLICK, clickHandler);
em_Mc.buttonMode = true; 
function clickHandler(event:MouseEvent):void 
{
TweenLite.to(em_Word, 1, {x:441.00, y:355.00, ease:Quad.easeInOut});
}

Link to comment
Share on other sites

Yeah,

I've got at nested moiveclip. I mean, one within another so I want to refer to the destination position of the inner mc but target the mc. For example: mc_Container.mc_Inner

So the target values here( x:441.00, y:355.0) is just the exact position on stage where that mc is but I want the tween to target the mc_inner MoiveClip itself on the stage.

TweenLite.to(em_Word, 1, {x:441.00, y:355.00, ease:Quad.easeInOut});

 

So for example:Can I do this?

TweenLite.to(em_Word, 1, {mc_container.mc_Inner, ease:Quad.easeInOut});

Link to comment
Share on other sites

A MovieClip's position is always described according to the local coordinates. But if you want to calculate what they'd be in an ancestor's coordinate system, you can use Flash's localToGlobal() and globalToLocal() methods.

 

var childPosition:Point = new Point(mc_Container.mc_Child.x, mc_Container.mc_Child.y);
var translatedPosition:Point = this.globalToLocal( mc_Container.mc_Child.localToGlobal( childPosition ) );

TweenLite.to(em_Word, 1, {x:translatedPosition.x, y:translatedPosition.y, ease:Quad.easeInOut});

Link to comment
Share on other sites

Thanks for your replies.

Actually, I took the target placeholder mc out of the other container mc and put it on top and the following code worked. :D

Sorry to confuse you! I was complicating things when it didn't need to be.

Thanks again.

TweenLite.to(em_Word, 1, {x:mc_Target, y:mc_Target, ease:Quad.easeInOut});

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...