A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Check if a function has finished to fire the next function? :(

  1. #1
    Junior Member
    Join Date
    Oct 2002
    Posts
    21

    Check if a function has finished to fire the next function? :(

    Hey there,

    I am currently trying my 5. workaround to get my menu done. . I want to move a series of 4 buttons up, after a click and when all buttons finished their movement I want the bottom 3 to move down again.

    My big problem ist, that I dont get a check working to see if the function move() hast finished in order to fire the function open(). Is there any listener or so?

    Here is my code:

    Code:
    //Setup and register with Zego Engine
    import com.mosesSupposes.fuse.*;
    ZigoEngine.simpleSetup( Shortcuts, PennerEasing, Fuse );
    //-----------------------------------------------------------
    
    //Setup Variables
    
    var projects_counter:Number = 1;
    //trace("initial projects_counter = "+projects_counter);
    
    var max:Number = 6;
    
    var myListener = new Object();
    //-----------------------------------------------------------
    
    function move() //starts the movement of all projects, y:"movement target in absolute coords")
    {
    for ( var s = 0; s < max; s++ )
          {
             var f:Fuse = new Fuse ();
             f.push ([
     				  	//{target: _root["project"+(projects_counter+1-s)], y: 100-(s*35), time: 1+(1/((1/s)+1)), ease:"easeOutQuint"}, //move all elements with smaller index than the clicked one
    				  	{target: _root["project"+ (projects_counter+s)], y: 100+(s*35), time: 1+(1/((1/s)+1)), ease:"easeOutQuint"} //move all elements with higher index and including the clicked one
    				]);
    	f.start();
    		
          }
    	  
    }
    
    
    function traceFunction()
    {
        trace("TWEEN COMPLETE")
    }
    
    
    function open() //opens the menu for the content, y:"opening value (relative distance)"
    {
    for ( var n = 1; n < max; n++ )
          {
             var f2:Fuse = new Fuse ();
             f2.push (
    				  	{target: _root["project"+(projects_counter + n+1)], y:"200", delay: 0.2, time: 2+(1/((1/n)+1)), ease:"easeOutBack"}
    				 );
    		 f2.start();
    		//trace("(open) n = "+n);
          }
    }
    
    _root.project1.onPress = function()
    {
    	projects_counter = 1;
    	move();
        move.addListener(Event.COMPLETE, traceFunction);
    }
    I attached the fla file, too.

    Many thanks in advance!!
    Attached Files Attached Files
    Last edited by OVI; 05-22-2011 at 09:08 AM.

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    maybe using a TWEENING class like TWEENMAX or even the TIMELINE MAX class would be a better solution for you?

    it has a stop, start, play reverse.. buy more importantly..

    is has the onComplete function where you can execute another function/action once that tween is done.


    www.tweenmax.com

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