3 Replies Latest reply on Mar 28, 2011 8:54 AM by Rothrock

    Please help - Problem with loading swf's (running very slowly)

      I have posted this problem up in the last few days so I built a quick demo of my problem. Can somebody please download it and take a look at it and see what I'm doing wrong?
      The external swf's when loaded.....run very very slow; sometimes unresponsive as if there is a script running in the background. I'm using keyboard commands to navigate through the screens - eg:
      on (keyPress "<Space>") {
      gotoAndStop("scene02", "firstframeLabel");
      Thank you for your help!!!!
        • 1. Re: Please help - Problem with loading swf's (running very slowly)
          Rothrock Level 5

          Few people here download files, so you are more likely to get help if you describe the problem or post a link to a webpage where people can see the problem.


          A few things to check.


          You don't mention how you are loading these external files. How many are there? Are you unloading them when you are done with each?


          You mention it seems that a script is runing in the background. Are there any other scripts other tha your keypress?


          Is the loading file set to the same frame rate as those being loaded? The framerate of the initial swf determines the rate for all loaded content.


          The next thing is that you probably shouldn't be using scenes. They are a great tool for animators to organize their work, but they can cause problems when interacting with code.


          And finally using on(event) type code placed on items themselves is an outdated technique that was generally abandoned quite a long time ago. Instead you should look into using a Key listener.

          • 2. Re: Please help - Problem with loading swf's (running very slowly)
            Kents79 Level 1



            I'm trying to use Key Listeners to solve my problem.

            I don't know much about key liseners so can somebody help me out.


            I have the following on a keyframe yet it still wont jump to the certain frames when I press the relevent keys. Am I missing something?



            KeyListener = new Object();
            KeyListener.onKeyDown = function() {

            if (Key.getAscii() == 38) {  // UP key

            if (Key.getAscii() == 40) {  // DOWN key

            if (Key.getAscii() == 37)  // LEFT key

            if (Key.getAscii() == 32) {  // SPACEBAR key
            loadMovie("application_01.swf", "container");}

            • 3. Re: Please help - Problem with loading swf's (running very slowly)
              Rothrock Level 5

              You are missing some things and got some other things wrong.



              var keyListener:Object = new Object();

              keyListener.onKeyDown = function() {

                  trace("Key down "+Key.getAscii());

                  trace("Key down "+Key.getCode());





              You have to add the object listener. Also you want to getCode and not the Ascii value. Also you are missing an opening curly brace on the LEFT. There is nothing wrong with using a bunch of if statements like that. But generally I find it hard to read and maintain. Here is a neat trick you might not know called a switch statment:





                   case Key.LEFT:

                   // do whatever for LEFT



                   case Key.UP:

                   // do whatever for UP



                   case Key.DOWN:

                   // do whatever for DOWN




                   // do something (or nothing) if any other key is pressed






              Finally with loadMovie you won't know when your external asset is loaded. So you should look into the MovieClipLoader class. With that you can tell when the external file is loaded and then do things with it.