A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: scripted tween not working properly

  1. #1
    Arabic Flash Guru sand_monkey's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    169

    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_DOWNGoToNextSlide);

    // function to call ChangeSlides() when next button is pressed
    function GoToNextSlide(e:MouseEvent)
    {
        var 
    n:Number 0;
        if (
    curSlide 8)
        {
            
    curSlide 1;
            
    ChangeSlides(n);
        }
    }

    function 
    ChangeSlides(n:Number)
    {
        if (
    != 0)
        {
            var 
    moveSlideTween:Tween = new Tween(slides"x"None.easeInslides.xxPos[1], 0.4true);
            
    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!

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center