A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Repeating frames once run certain amount of times

  1. #1
    Senior Member
    Join Date
    Jul 2008
    Posts
    117

    Repeating frames once run certain amount of times

    I know this should be devastingly easy to do, but help!

    I have a movieclip - I'm using AS2 - I want the movieclip to repeat its own frames 1-16, twenty times in a row. Once this has happened I want the movieclip to go to frame 17 and play itself to the end.

    My movieclip instance is called "test".

    My code on frame 16 in the movieclip is

    Code:
    "trace ("test" + i)
    if (i >= 20)
    {
    	gotoAndPlay (17);
    }
    else 
    {
    	gotoAndPlay (1);
    	
    }


    which is probaby pointless as I can't access the "i" variable from there??


    The code on my movieclip is:

    Code:
    onClipEvent(enterFrame) {
    	for (var i:Number = 0; i < 20; i++) {
    	trace (i)
    	if (i < 20)
    	test.gotoAndPlay(1);
    	}
    	
    	if (i >= 20)
    	{
    		test.gotoAndPlay(17)
    	}
    }

    I apologise in advance for being a thick. All help most welcome.

    Cheers.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    on the last frame of the loop (frame#16)
    no onEnterFrame code needed.

    PHP Code:
    function init(){
    if(!
    inited){
    0;
    inited true;
    }
    ++
    i==20 gotoAndPlay(17) : gotoAndPlay(1);
    trace(i);
    };

    init(); 

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    117
    cheers very much!

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