A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Target Movie Clip After X loops

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    2

    Exclamation Target Movie Clip After X loops

    I'm a scripting novice, so here goes:

    Using Flash 9 / AS3:

    I have a movie clip - we'll call it mc1.

    If I have mc1 appear on the main stage timeline of my swf and I want it to play 5 times, and then stop on the last frame of the movie clip, how would I do this?

    Obviously this can be done easily with timeline animation I'm interested in knowing how to script it for more elaborate application.

    Thanks!

    -Ben

  2. #2
    You can use this method essentially, at runtime the clip will go to the first frame, and if count does not exist in that frame it will create it. Then count will add 1 to itself every time it hits the last frame until count is equal to 5, and if so the movieclip will stop.

    First frame put:

    Code:
    if(this.count==undefined){
    	this.count=0;
    }
    Last frame put:

    Code:
    this.count++;
    
    if(this.count==5){
    	stop();
    }

    Personally I hate dynamically creating variables like that, but it will work. I'm sure there is probably a better way.

    Hope this helps ,

    TariqM

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    2
    Thanks man this is exactly what I need for now.

    Why don't you like creating dynamic variables because they can get out of hand, or what?

  4. #4
    When you create the variables at runtime they just cause confusion for developers later on, basically your right they can get out of hand. They also make it harder to debug code in my previous experience.

    They are fine for quick projects, but in real big projects I wouldn't suggest using them.

    Some love them and may disagree with me though.

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