Jump to content
Search Community

Possible to Tween to a negative position when not a number

heyitsjayy test
Moderator Tag

Recommended Posts

So we all know that it's possible to Tween to a negative position, like so:

TweenMax.to(MovieClip, 1, {x:-500})

 

Though what about sitations when you're tweening something to an X or Y position, that is not a number, like so:

 

TweenMax.to(slider.firstMC, 0, {y:slider.secondMC.x}); (where X is a positive value)

 

Is there a way thats possible to tween that to the negative of that position, for example like:

TweenMax.to(slider.firstMC, 0, {y:-slider.secondMC.x});

TweenMax.to(slider.firstMC, 0, {y:"-slider.secondMC.x"});

or TweenMax.to(slider.firstMC, 0, {y:-"slider.secondMC.x"});

 

 

None of these worked, by the way, for reasons that are understandable.. which is reason for the festive post here :)

So just wondering if it's possible to tween to a negative, or a reverse/opposite of that number, x position that is already positive, in some way?

Link to comment
Share on other sites

I think what you are trying to say is that you want a negative value to be treated like a String so that your end values are relative and not absolute like this:

 

TweenLite.to(mc, 1, {x:String(-mc.width)});

 

Does that help?

Link to comment
Share on other sites

Thanks guys for the answers. Yeah I realize it's a bit hard to describe in words, when not knowing the answer to what needs to be accomplished :)

 

Here I'll try and provide a clearer explanation and a .Fla demo here.

What was trying to be done was have this scroller slideshow "look" like it rotates in a cycle, so theere will be 4 total items.

 

There will be 6 total slides, The 4 main items are pushed forward one slide / down the slider & each Movieclip being placed on top of each of the other MCs' positions.

 

This is to "clear" the first & last slide (1& 6) to make room for two MovieClip items 1 and 4 to be placed on the first and last slide... so again it'll fake looking like its a "cycle"/repeat of items. Hopefully making sense?

 

Reason for needing negative placement.. is the last MoveClip6, Needs to go back a slide to the negative, on top of MovieClip1. And all items are relative to Movieclip1 since this one will be the first loaded in.

 

Knowing this code is wrong, but supplying it for a demo purpose anyway:

TweenMax.to(slider.mc6, 0, {y:String(-slider.mc1.y)});

TweenMax.to(slider.mc1, 0, {y:slider.mc1.y *2});
TweenMax.to(slider.mc2, 0, {y:slider.mc1.y *3});
TweenMax.to(slider.mc3, 0, {y:slider.mc1.y *4});
TweenMax.to(slider.mc4, 0, {y:slider.mc1.y *5});

TweenMax.to(slider.mc1, 0, {y:slider.mc6.y});

 

Also here is a link to show a little better. This wasn't totally working by the way (movieclips just werent appearing, or not in right places), which is why i'm hoping someone can help!

Really looking for advice here...Maybe this would be better off using a different method altogether, and not using Greensock tweens at all?

Possibly using 'addChild' would suffice. .. ALA, like in carl's fireside chat on addChild & nested MC's: http://www.snorkl.tv...-with-addchild/ Ahhh fireside chat, sounds so comforting.

Link to comment
Share on other sites

The reason the code above (and in your file) wasn't working) is because when that code runs, slider.mc1.y = 0. So that means that every time you multiply that number by something else: 2, 3, 4, 5 you are going to get 0. So basically all clips had a y of 0 and were sitting on top of each other.

 

I think you intend to use the height of slider.mc1 and not the y

 

maybe something like this:

 

 

var padding:Number = 19;

var clipOffset:Number = slider.mc1.height + padding;

 

TweenMax.to(slider.mc1, 0, {y:0 });

TweenMax.to(slider.mc2, 0, {y:clipOffset });

TweenMax.to(slider.mc3, 0, {y:clipOffset *2});

TweenMax.to(slider.mc4, 0, {y:clipOffset *3});

 

also, not sure why you would use tweens for this instead of just setting the y directly like:

 

slider.mc4.y = clipOffset *3

 

I also see that you are trying to set the position of mc1 twice which is a bit confusing

 

I have to admit, that I've tried really hard to understand your description but I'm still quite lost :|

  • Like 1
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...