Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Fitchett Developments

hitTestObject not working when Tween added

Recommended Posts

Hey guys quick question. Do you know of any reason to why my hitTestObject wont initiate when i add this line to my mcPlayer Class:

 

TweenMax.to(this, 1.5, { x:120, ease:Power0.easeInOut } );

 

 

My hitTest function works perfectly fine but once i add this code to it, my player just goes straight through the object  this is how my mcPlayer class is setup

 

 

public class mcPlayer extends MovieClip
    {
        
        public function mcPlayer()
        {
            addEventListener(Event.ADDED_TO_STAGE, onAdd);
        }
        
        private function onAdd(e:Event):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, onAdd);
            init();
        }
        
        private function init():void
        {
          TweenMax.to(this, 1.5, { x:120, ease:Power0.easeInOut } );
        }

 

 

Link to post
Share on other sites

Hm, tough to say without seeing your file and publishing it on our end, but I wonder if it's just because you're moving the object, so it's not hitting when you call that method? Keep in mind, all TweenMax is doing is changing this.x multiple times over the course of 1.5 seconds. That's it. Nothing else. You could literally do the same thing in your own loop (although you'd lose a ton of conveniences, but my point is that you don't need to be suspicious of TweenMax doing fancy footwork under the hood, removing the target and somehow interfering in other ways - it's just setting the x property). 

 

If you're still having trouble, please feel free to post a super-simple example FLA here (zip it first) and we'll take a peek. (click the "More Reply Options" below)

Link to post
Share on other sites

Thanks for the information it helped i think it has something to do with the object it runs into, because like i stated above whenever i change its position closer to the mcPlayer the hit test works.

 

 

But while i have you hear i have another quick question.

 

In one of my Object Classes i wan it to alpha ease in whenever its added to the stage. So i want it to be invisible then ease in after 1 second. I have this:

 

TweenLite.to(this, 1, {autoAlpha:0});

 

But it eases out. I tried to mess with it but couldnt really get it to work.

Link to post
Share on other sites

Just change "to" to "from" because you're wanting to tween from autoAlpha:0 to whatever it is now (I assume alpha:1). 

TweenLite.from(this, 1, {autoAlpha:0});

Or you could do this:

this.alpha = 0;
TweenLite.to(this, 1, {autoAlpha:1});
  • Like 1
Link to post
Share on other sites

autoAlpha:0 will fade out the target to alpha == 0 and visible == false.

 

You probably want autoAlpha:1, but to fade in the target it will also need to be invisible at the start of the tween i.e.

this.alpha = 0;
TweenLite.to(this, 1, {autoAlpha:1});

// or even shorter

TweenLite.fromTo(this, 1, {autoAlpha:0}, {autoAlpha:1});
Link to post
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.

×