3 Replies Latest reply on Jul 3, 2006 9:23 PM by Mike_Eazy

    dynamic text problem

    Mike_Eazy Level 1
      OK, I load a sound.swf into a empty movie clip for my mp3 swf, and I have the dynamic text field (which is called "display") to show the song information when the file has 100 percent loaded. And when I click the next button I want it to show the information of the next song. The problem is when I click the next button it seems as if the code loops because the info shows really quick and then changes back to the original information. Here is an example of the code:

      [CODE]onClipEvent(load){
      loadMovieNum("sound.swf",1);
      _root.prev_btn1.enabled=false;
      _root.next_btn1.enabled=false;
      _root.stop_btn.enabled=false;
      _root.pause_btn.enabled=false;
      }

      onClipEvent(enterFrame){
      percentloaded=Math.floor(_level1.getBytesLoaded()/_level1.getBytesTotal()*100);
      _root.display="Loading..." + percentloaded + "%";
      if(percentloaded == 100){
      _root.display= "artist1 - song title1";
      initialized=true;
      _visible=false;
      _root.stop_btn.enabled=true;
      _root.pause_btn.enabled=true;
      _root.next_btn1.enabled=true;

      }
      }


      _root.next_btn1.onPress = function(){
      _level1.mySound1.stop();
      _level1.mySound2.start();
      _root.next_btn1.enabled=false;
      _root.prev_btn1.enabled=true;
      _root.display="artist2 - song title2";
      }
      _root.prev_btn1.onPress = function(){
      _level1.mySound2.stop();
      _level1.mySound1.start();
      _root.prev_btn1.enabled=false;
      _root.next_btn1.enabled=true;
      _root.display= "artist1 - song title1";
      }
      }


      [/CODE]
        • 1. Re: dynamic text problem
          NSurveyor Level 2
          You seem to be using old syntax.. onClipEvent(), it really has its disadvantages as you can't delete them. E.g. deleting the enterFrame which is causing your problem. onEnterFrame is constantly looping and the percent loaded will eventually remain at 100, and thus as your code shows, it will show the original info. So, let's update your code, this code can go on a frame like your other code:

          loadMovieNum("sound.swf",1);
          _root.prev_btn1.enabled=false;
          _root.next_btn1.enabled=false;
          _root.stop_btn.enabled=false;
          _root.pause_btn.enabled=false;
          onEnterFrame = function(){
          percentloaded=Math.floor(_level1.getBytesLoaded()/_level1.getBytesTotal()*100);
          _root.display="Loading..." + percentloaded + "%";
          if(percentloaded == 100){
          _root.display= "artist1 - song title1";
          initialized=true;
          _visible=false;
          _root.stop_btn.enabled=true;
          _root.pause_btn.enabled=true;
          _root.next_btn1.enabled=true;
          delete onEnterFrame;
          }
          }

          By the way, you shouldn't use: percentloaded == 100 as percentloaded is a rounded value, thought it doesn't really make a difference. It's better to use something like: _level1.getBytesLoaded()/_level1.getBytesTotal()>=1
          • 2. Re: dynamic text problem
            Mike_Eazy Level 1
            ok, but the code is in a empty movie clip so the sound can be loaded, so i have to use the onClipEvent or it will be errors, any way to make that work?
            • 3. Re: dynamic text problem
              Mike_Eazy Level 1
              Anybody else wanna help? I tried using the MovieClip.onEnterFrame and onLoad but it doesnt work.