A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [F8] onMotionFinished and globals

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Posts
    14

    [F8] onMotionFinished and globals

    I'm trying to call something when a tween motion is finished. However it isn't working. I believe it is because the tween is being created in a function. I tried assigning global to it, but flash doesn't allow that for strict data types according to documentation. I call the glideup() function from a button. That part works, but the trace("finished") doesn't.

    Here is my code:
    Code:
    //makes the logo glide up
    function glideup() {
    	var yMove:Tween = new Tween(mylogo, "_y", Bounce.easeOut, mylogo._y, mylogo._y - 160, 2, true);
    }
    
    //after glideup() is finished, this is called
    yMove.onMotionFinished = function() {
    	trace("finished");
    }

  2. #2
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    its not working because you are defining yMove locally to the glideup() function,

    define the variable yMove outside of the function like this:

    Code:
    var yMove:Tween
    function glideup() {
    	yMove = new Tween(mylogo, "_y", Bounce.easeOut, mylogo._y, mylogo._y - 160, 2, true);
    }
    
    //after glideup() is finished, this is called
    yMove.onMotionFinished = function() {
    	trace("finished");
    }
    or assign the onMotionFinished locally like so:
    Code:
    function glideup() {
    	var yMove:Tween = new Tween(mylogo, "_y", Bounce.easeOut, mylogo._y, mylogo._y - 160, 2, true);
                 yMove.onMotionFinished = function() {
    	    trace("finished");
                }
    }
    HTH,

    zlatan
    Last edited by dudeqwerty; 07-30-2006 at 11:18 AM.
    New sig soon

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