dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: sequence of functions

  1. #1
    Junior Member
    Join Date
    Nov 2006
    Posts
    17

    sequence of functions

    Hi
    How can I make this?
    I want one function to start first, and when this function is done, then a new function will start.
    This is the code or so:

    Code:
    var timeline: MovieClip = this;
    var counter: Number = 0;
    
    timeline.inicial.onRelease = function(1 ){
    	if(timeline.counter < 10){
    	var newClip: MovieClip = this.duplicateMovieClip("copia" + timeline.counter, timeline.getNextHighestDepth() );
    	timeline.counter++;
    	newClip._x = 50 + timeline.counter*80;
    	newClip._y = 20 + timeline.counter;
    	}
    }
    timeline.inicial.onRelease = function( 2)
    {
    	var newClip: MovieClip = this.duplicateMovieClip("copia" + timeline.counter, timeline.getNextHighestDepth() );
    	timeline.counter++;
    	newClip._xscale *= -1;
    	newClip._x = 90 + timeline.counter*80;
    	newClip._y = 20 + timeline.counter;
    	
    }
    As it is now, I only get the second function.
    Thanks in advance

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    var timelineMovieClip this;
    var 
    counterNumber 0;

    timeline.inicial.onRelease = function(){
        if(
    timeline.counter 10){
    var 
    newClipMovieClip this.duplicateMovieClip("copia" timeline.countertimeline.getNextHighestDepth() );
        
    timeline.counter++;
        
    newClip._x 50 timeline.counter*80;
        
    newClip._y 20 timeline.counter;
    }
    two();
    };

    function 
    two(){
    trace("function two called");
    var 
    newClipMovieClip this.duplicateMovieClip("copia" timeline.countertimeline.getNextHighestDepth() );
        
    timeline.counter++;
        
    newClip._xscale *= -1;
        
    newClip._x 90 timeline.counter*80;
        
    newClip._y 20 timeline.counter;
    }; 

  3. #3
    Junior Member
    Join Date
    Nov 2006
    Posts
    17
    Thanks, dog, but it works crazy. Function two starts when it shouldn't ...
    Problably the problem is in my code of functions.
    They should first complete a line of blocks with a separation among them and then the second part should fill the holes with the same block but reversed.
    Any suggestions?

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try passing the counter as a parameter, and only when it
    has reached 10, run the function two duplication -
    PHP Code:
    var timelineMovieClip this
    var 
    counterNumber 0

    timeline.inicial.onRelease = function(){ 
        if(
    timeline.counter 10){ 
    var 
    newClipMovieClip this.duplicateMovieClip("copia" timeline.countertimeline.getNextHighestDepth() ); 
        
    timeline.counter++; 
        
    newClip._x 50 timeline.counter*80
        
    newClip._y 20 timeline.counter

    two(timeline.counter); 
    }; 

    function 
    two(num){ 
    trace("num ="+num); 
    if(
    num>10){
    var 
    newClipMovieClip this.duplicateMovieClip("copia" timeline.countertimeline.getNextHighestDepth() ); 
        
    timeline.counter++; 
        
    newClip._xscale *= -1
        
    newClip._x 90 timeline.counter*80
        
    newClip._y 20 timeline.counter
    }
    }; 

  5. #5
    Junior Member
    Join Date
    Nov 2006
    Posts
    17

    solved

    I finally solved the functions with an if/else condition:
    Code:
    var timeline: MovieClip = this;
    var counter: Number = 0;
    
    timeline.inicial.onRelease = function( )
    {
        if(timeline.counter < 10){
            var newClip: MovieClip = this.duplicateMovieClip("copia" + timeline.counter, timeline.getNextHighestDepth() );
            timeline.counter++;
            newClip._xscale *= -1;
            newClip._x = 90 + timeline.counter*80;
            newClip._y = 110 + timeline.counter;        }
    	else{
        var newClip: MovieClip = this.duplicateMovieClip("copia" + timeline.counter, timeline.getNextHighestDepth() );
            timeline.counter++;
            newClip._x = 50 + (timeline.counter*(80)-440);
            newClip._y = 110;    
        }
    }
    Anyway, thanks for your great help and inspiration.

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