Jump to content
Search Community

Issue w/tweening after changing movieclip frame [SOLVED]

swiftmend test
Moderator Tag

Recommended Posts

Hi, I'm building a game, and using tweenmax as the enemies pathfinding (which works brilliant!)

 

Basically the enemy has a class attached to him, which, after he is spawned via code outside his class goes through and adds the tween, etc to him, BUT if I change that enemies frame in his own class the tween for some reasons stops after it moves to the first position... any clue why this would be? I can't figure it out for the life of me.

 

public function Enemy(code:int)

{

this.addEventListener(Event.ADDED, beginClass);

this.addEventListener(Event.ENTER_FRAME, eFrameEvents);

level = code;//set the level to the value passed in for use in other functions

}

private function beginClass(e:Event):void

{

_root = MovieClip(root);//defining the root

health = level * 5;

if (level == 1)

{

this.gotoAndStop(2); <--- THIS IS ISSUE: It changes his appearance all well and good, but seems to break the tween.

}

TweenMax.to(this, 20, {bezier:[{x:_root.wp2.x, y:_root.wp2.y}, {x:_root.wp2.x, y:_root.wp2.y}, {x:_root.wp3.x, y:_root.wp3.y}, {x:_root.wp4.x, y:_root.wp4.y}, {x:_root.wp5.x, y:_root.wp5.y}], orientToBezier:true});

}

Link to comment
Share on other sites

Nope, I can't think of a good explanation unless you have code on that other frame that would interfere with the tween. It's tough to troubleshoot without being able to see an example FLA - any chance you could post one? No need to post your production files - just whip together a super-simple FLA that reproduces the issue. (oh, and don't forget to zip your file(s) before posting them)

Link to comment
Share on other sites

Yep, it looks like an issue in your code - your beginClass() is getting called over and over again for the problem graphic, and that method is where your tween code is too, so it's spawning a bunch of tweens, each of which overwrites the previous one and I'd be willing to bet that the values you're plugging into the tween have changed by the last time beginClass() gets called for that item.

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