Jump to content
Search Community

Tween with different behaviors?

NIKESLB test
Moderator Tag

Recommended Posts

Hi.

After few weeks using Tweens from Greensock, I'm still confused with his behavior.

 

Example:

TweenLite.to(this.sprite, 1, {y:5});

Supposedly, my object will go to the top. Sometimes it happen and sometimes is different.

Right now I have an object at the middle of the stage (y=400), if I use the previous code, he is not going to the top, but moves +5 in y  (y = 405).

 

So my question is what I need to do for my object go to the top and not +5?

Link to comment
Share on other sites

Hi,

 

Is a weird situation just tested something similar and is working for me:

import com.greensock.*;

TweenMax.to(mc, 1, {y:5});

Please check the file attached to the post:

 

 

What version of the engine you're using? did you downloaded the latest?.

 

Also It'll help if you could provide a simple sample of what's giving you problems.

 

Hope this helps,

Cheers,

Rodrigo.

Link to comment
Share on other sites

That is certainly strange, as {y:5} should NEVER tween to y=y+5. The only thing that comes to mind is that String values are interpreted as relative in GSAP actionscript:

// absolute: will ALWAYS tween sprite to y=5
TweenLite.to(this.sprite, 1, {y:5});

// relative (deprecated): will ALWAYS tween sprite to y=y+5
TweenLite.to(this.sprite, 1, {y:"5"});

// relative: will ALWAYS tween sprite to y=y+5
TweenLite.to(this.sprite, 1, {y:"+=5"});

If you are passing the y value as a variable, make sure that it is of type Number (or int etc) and not String. If you have a String but would like an absolute tween, you can cast it to a Number like this:

var newy = "5";
TweenLite.to(this.sprite, 1, {y:Number(newy)}); // absolute
  • Like 1
Link to comment
Share on other sites

yes I have the latest. I tried the example and yes It works.
I'll show a sample of my code:

public function Class{
     ....
     //Line
            this.lineHori = new Shape();
            this.projet.getPalco.addChild(this.lineHori);            
            this.lineHori.graphics.lineStyle(7, 0xFFFFFF, 1);
            this.lineHori.graphics.moveTo(20, this.projet.getPalco.stageHeight/1.3+61);
            this.lineHori.graphics.lineTo(150, this.projet.getPalco.stageHeight/1.3+61);

     createSub(this.projet.getPalco.stageHeight/1.3, "Aplication");
     createSub(this.projet.getPalco.stageHeight/1.3, "Images");
     ...
}

//y value and text
private function createSub(vY:Number, myText:String){ 
            spriteTextMenu = new Sprite;
           
            var textMenu:TextField = new TextField;
            textMenu.selectable = false;
            textMenu.width = 200;
            textMenu.height = 25;
            textMenu.text = myText;
            this.spriteTextMenu.addChild(textMenu);
            
            this.spriteTextMenu.buttonMode = true;
            this.spriteTextMenu.mouseChildren = false;
            this.spriteTextMenu.name = myText;
            this.spriteTextMenu.y = vY;
            this.spriteTextMenu.x = 30;
            this.spriteTextMenu.width = 150;
            this.spriteTextMenu.addEventListener(MouseEvent.MOUSE_OVER, menuOver);
            this.spriteTextMenu.addEventListener(MouseEvent.CLICK, menuClickRemovePrevious);
            this.projet.getPalco.addChild(this.spriteTextMenu);    
        }

        private function menuOver(e:MouseEvent):void{                      
            TweenLite.to(this.lineHori, 2, {y:10});
        }
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...