-
Arabic Flash Guru
scripted tween not working properly
I have a scripted tween which is not working properly. the idea is that when i click a button this massive movieclip (8000 pixels wide), moves along 1000 pixels (the width of the stage) to show the next slide. Sometimes, and randomly, it stops in the middle of the tween, if you click the button again, it goes to the next slide as if the previous one had worked correctly.
this is the code i am using...
PHP Code:
navigation.nextBtn.addEventListener(MouseEvent.MOUSE_DOWN, GoToNextSlide);
// function to call ChangeSlides() when next button is pressed
function GoToNextSlide(e:MouseEvent)
{
var n:Number = 0;
if (curSlide < 8)
{
n = curSlide + 1;
ChangeSlides(n);
}
}
function ChangeSlides(n:Number)
{
if (n != 0)
{
var moveSlideTween:Tween = new Tween(slides, "x", None.easeIn, slides.x, xPos[n - 1], 0.4, true);
curSlide = n;
tweenNo++
}
}
when i trace xPos[n - 1] (an array) it comes out with a value that is expected - eg. where the movieclip should finish. but when i trace the x value of the movieclip it is not equal to where the tween should finish
can anyone see what is going on?
Sand Monkey
Flying is learning how to throw yourself at the ground and miss!
-
Bearded (M|G)od
Declare the tween variable in the class level. As in, define it outside of the function.
var moveSlideTween:Tween;
Then in your function just call:
moveSlideTween = new Tween(.....);
The reason it's stopping randomly is because of garbage collection. As soon as that function is finished running, the moveSlideTween variable is unreachable and marked for garbage collection.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|