4 Replies Latest reply on Oct 26, 2007 12:24 PM by kglad

    Delay inside function

    artishox
      Hi i am trying to make function that loads variables from file and returns them as an array but there is problem i need delay to in this function because variables cannot be loaded so fast as function goes.

      the problem is that I need that onLoad executes before return aVariables

      can sameon help me?
      thanks.

      p.s. I use Macromedia Flash Profesional 8
        • 1. Re: Delay inside function
          ChrisElmes
          try putting the return variables INSIDE the onLoad function - that way they wont be returned until the onLoad is called
          • 2. Re: Delay inside function
            IwannaFlashU
            Yes, the vars need to be at the bottom of the if(bSuccess) code group. ALSO, if your project uses the timeline (ie you load them in frame 1 the movie continues to play) you will need to put a stop(); on the frame where you load the vars and then at the end of the if(bSuccess) code group, have play();

            If you don't do that, half the time your variables will get read and the other half they won't because while flash is going out to get the vars, the timeline has moved on and left them behind.
            • 3. Re: Delay inside function
              artishox Level 1
              i have tried to put return in onLoad function then i get error that getVariables function hasno return statement
              • 4. Re: Delay inside function
                kglad Adobe Community Professional & MVP
                correct. so, don't use a return in your onLoad method. simply define your array aVariables in you onLoad method and then call another function passing your array as a parameter. or don't make your array local to getVariables.