Jump to content
Search Community

Very strange behavior..need some help [SOLVED]

zed test
Moderator Tag

Recommended Posts

I everyone!

I'm new to tweenLite, but.. congrats, very usefull, very simple.

I am having a problem:

 

I have a box_mc, and inside it i have a btn_mc

I know thati cannot give action to box_mc directly, cause the actions inside will not work, So i give the action to a "animbox_mc" inside box_mc, like this:

 

//show the box with tweenLite
_root.box_mc_mc.animbox_mc.onRollOver = function() {	
TweenLite.to(_root.box_mc, 0.5, {_x:0, ease:Expo.easeInOut});
}

 

It works great, but when i go and give the actions to the button like this:

 

//giving actions to the button inside box_mc
_root.box_mc.btn_mc.onRollOver = function() {
_root.box_mc.btn_mc.gotoAndStop(2);
}

 

it will mess up with the main box_mc (the box will return to it´s original position, the object flikrs, nothing works..

Only until i thought of this crazy idea, to include a tweenlite in the object action fucntion, like this:

 

//giving actions to the button inside box_mc
_root.box_mc.btn_mc.onRollOver = function() {

//i need to put another tween to the box_mc this time without time, because i dont want the box to move, but this way it works, even if it is a kind of odd way...
       TweenLite.to(_root.box_mc, 0, {_x:0, ease:Expo.easeOut});
_root.box_mc.btn_mc.gotoAndStop(2);
}

 

any ideas?

thanks in advance

zed

Link to comment
Share on other sites

There must be something else going on in your code - please post a simplified FLA that demonstrates the problem. Again, please strip out ALL the extra functionality so that the problem is isolated in this separate FLA. I'm sure we can figure it out. (don't forget to zip your FLA before posting).

Link to comment
Share on other sites

Hi GreenSock, tanks for the reply

 

here is a simplified example of my problem...hope you can help me. The solution i found is not very interesting to apply, and makes the actions code very confusing, since i'm going to have some buttons to give actions to

 

hope you can give it a look

 

cheers

zed

Link to comment
Share on other sites

Ah yes, this has nothing to do with a problem in the tweening engine - it's just a logic issue in your code. When you rollOver the button, it also triggers the rollOut of the animbox_mc! So your rollOut is causing a new tween to begin that moves box_mc back, but it sounds like you don't want that to happen if the user is rolled over the button, so you'd need to put conditional logic in there to do that (only trigger the rollOut tween if the button is not rolled over). The reason your code worked when you added that other zero-duration tween is that it immediately overwrote the rollOut tween that would have otherwise moved box_mc back.

 

Understand?

Link to comment
Share on other sites

Thanks for the help, off course it makes sense, even if i could really understand why the actions of the buttons interfer with the action of the main box...

I will try to put it all in a function, and then triger only the function.. that way i can have less code, because from what i understood, the logical conditions will be needed in the on() actions.. so i will have to write them everywhere.

 

cheers

zed

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...