1 Reply Latest reply on Nov 6, 2009 5:54 AM by clbeech

    onEnterFrame in a dynamic movieclips array

    Parsa Ghaffari

      Hello there,

      What I'm trying to do is, generating some movieclips in a loop and putting them into an array and then enumerating the array and set an endpoint for each instance of that movieclip:

       

      mc[i].onEnterFrame=function(){
           this._y -=8/N;
           if((getTimer()-lastT) > myLevel){
                this.onEnterFrame=function(){}
           }
      }
      

      lastT is the time where the scene was run for the first time. So i'm comparing the time for each instance to that "initial time" and check if its larger than myLevel which varies for each of the instances. So this code first runs for all the instances, each having a different "myLevel", then I expect to see they moved differently. But the result I currently get is all of the instances move to the lowest "myLevel" value and then stop. How can I fix this?

       

      Thanks for your time

      Parsa

        • 1. Re: onEnterFrame in a dynamic movieclips array
          clbeech Level 3

          I'm not quite certain that i'm following what you trying to do entirely - but if each instance has an independant property called 'myLevel' - you need to target the instance to retrieve the property, eg. this.myLevel (while within the scope as your code is designed)

           

          additionally the correct way to stop an enterframe loop is to use:

           

          delete this.onEnterFrame;

           

          - which really may be the main issue

          1 person found this helpful