dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: loop crashing flash

  1. #1
    Senior Member
    Join Date
    Aug 2005
    Posts
    170

    loop crashing flash

    Code:
    for(i=0;i<10;i++){
    	duplicateMovieClip (this,"star"+i,i)
    }
    I can't see whats wrong.
    it should run 10 times then stop but when i preview it it stays the code is causing flash to run slow.

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    Where is this code? Timeline of a movieclip i'm assuming. Well when you are refering to 'this' it means please duplicate this timeline 10 times..it is not saying please duplicate the 'mc graphic' 10 times..

    what you need to do is give the movieclip an instance name, and then from the maintimeline duplicate it 10 times...

    e.g give it a name "mc" and then on the first frame of the maintimeline or whichever frame your movieclip will first appear on put

    Code:
    for(i=0;i<10;i++){
    	duplicateMovieClip (mc,"star"+i,i)
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    dubba you tee eff steven_h_2000's Avatar
    Join Date
    Oct 2000
    Location
    Columbus, Ohio
    Posts
    137
    It's because you are duplicating a movie clip that has that code inside of it, so each instance that has been created via as a duplicate of the original, it is running that code!!!!

    try something like this, if you MUST have that code within the movie clip:

    Code:
    if (_parent.starIsDupped == undefined) {
    	for(i=0;i<10;i++){
    		duplicateMovieClip (this,"star"+i,i)
    	}
    	_parent.starIsDupped = true;
    }

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