# Strange AS3 next/prevFrame() behaviour

**URL:** <https://forum.kirupa.com/t/strange-as3-next-prevframe-behaviour/235922>\
**Category:** Uncategorized\
**Created:** [August 15, 2007, 7:38pm UTC](https://forum.kirupa.com/t/strange-as3-next-prevframe-behaviour/235922 "2007-08-15T19:38:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![frantic99](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@frantic99](https://forum.kirupa.com/u/frantic99)\
**Post date:** [August 15, 2007, 7:38pm UTC](https://forum.kirupa.com/t/strange-as3-next-prevframe-behaviour/235922/1 "2007-08-15T19:38:57Z")

</div>

Hi guys,

I’m migrating some stuff to AS3 and have come to a dead end with this one.

Here’s 2 examples to help you understand the problem: They present the difference between the AS3/AS2 implementation.

[http://users.ntua.gr/el02173/prevFrame.zip](http://users.ntua.gr/el02173/prevFrame.zip)

What you see is this: on the stage there’s a movieclip called ball, which contains a 20-frame scale tween of another movieclip, called colorchange which contains a 40-frame color tween of a circle.

So, I’ve got sth like this: root–\> ball (scale tween of colorchange - 20 frames) --\> colorchange (color tween of a shape - 40 frames)

So, suppose I want to use ball as a button with a rollover effect that plays backwards… In AS2 I used the following code to enable the scale tweening (ball plays forwards when the mouse is over the shape, and backwards when the mouse is elsewhere):

ball.onEnterFrame = function() {  
if (ball.hitTest(\_root.\_xmouse, \_root.\_ymouse, true)) {  
ball.nextFrame();  
} else {  
ball.prevFrame();  
}  
};

Note that mc colorchange plays without any problem continuously. Check the file as2prevFrame.swf in the zip above.

Now, I migrated to AS3 and expected this to work:

ball.addEventListener(Event.ENTER\_FRAME, HitTest);

function HitTest(e:Event) {  
if (ball.hitTestPoint(root.mouseX, root.mouseY, true)) {  
ball.nextFrame();  
} else {  
ball.prevFrame();  
}  
}

Check out what’s happening (as3prevFrame.swf): The prevFrame() and nextFrame() actions on “ball” are blocking “colorchange” from playing properly. See the difference between the 2 swf’s? What’s the deal with this behavior? There is nothing in the code above that should stop the color tweening from playing properly, like it did with AS2.

I 've got plenty of experience with flash, but I can’t figure out what to do with this one. Your insight will be much appreciated, because I’ve been making my flashier buttons like this for ages… and I’m at a dead end. Thanks.
