A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Wait then duplicate?

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Wait then duplicate?

    I have a mc that needs to be duplicated 10 times. Now the catch is it needs to be duplicated every 0.5 seconds. I cant get it to work. its realy simple just dunno what ive done wrong. Please help

  2. #2
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    Code:
    var counter = 0;
    
    // 500 here is milliseconds = 0.5 seconds
    var myInterval = setInterval(dupMC, 500);
    
    function dupMC()
    {
       counter++;
    
       // DUPLICATION CODE IN HERE
    
       if (couter == 10) {
          // stop the function interval when reach 10...
          clearInterval(myInterval);
       }
    }
    something like that should do it.
    jonmack
    flash racer blog - advanced arcade racer development blog

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks for that.It works but theirs one thing wrong with it. I think the if statement doesnt work

    if (couter == 10) {
    // stop the function interval when reach 10...
    clearInterval(myInterval);
    }


    still duplicates.

    And another thing with the dupliceMovieclip is their anyway to make it so that its duplicated onto the level under the previous one duplicated.

  4. #4
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    Didn't work? Really? Worked fine for me. D'oh! I see the problem, i edited the code in flashkit, and misspelt counter! The if statement should read

    if (counter == 10) { etc.

    Sorry!

    You could use (10 - counter) i suppose for the depth of the movieclip, so something like

    attachMovie("linkage", "newname"+counter, 10-counter);

    That should do it. Just make sure you keep track of which levels they are going on, and that they're not replacing anything. If you wanted them to go on higher levels, use a higher number, like 50-counter.
    jonmack
    flash racer blog - advanced arcade racer development blog

  5. #5
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    LOL cant believe i missed the spelling. Thanks for your help

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