1 Reply Latest reply on Jun 28, 2007 12:46 PM by genotype

    onPress in class def?

    genotype
      Using onPress within my class definition seems to work sometimes and not others. I started with a small test file called Test.as

      class Test extends MovieClip{
      function onPress() {
      trace("howdy");
      _level0.status_txt.text = _level0.html_var;
      }
      }
      In my test.fla file i have a single movieclip with the AS 2.0 Linkage property set to Test, gave it an identifier, etc. It works fine.

      My real class is SoundPlayer.as:
      class SoundPlayer extends MovieClip{
      function onPress() {
      trace("howdy");
      }
      var loaded_sounds_array:Array = new Array();
      function onLoad() {
      var i;
      if (_level0.file_names_array){
      for (i = 0; i <= _level0.file_names_array.length-1; i++){
      var new_sound:Sound = new Sound();
      new_sound.loadSound(_level0.file_names_array , false);
      loaded_sounds_array.push(new_sound);
      //loaded_sounds_array
      .start();
      }
      } else _level0.status_txt.text = "no files found";
      }

      function playSounds(){
      var current_sound:Number = 0;
      loaded_sounds_array[current_sound].start();

      loaded_sounds_array[current_sound].onSoundComplete = function():Void {
      current_sound++;
      if(current_sound < loaded_sounds_array.lenth) {
      loaded_sounds_array[current_sound].start();
      }
      }

      }


      }


      I tried the onPress block in several differnent places within the class, deleted everything but the onPress block, nothing seemed to help.

      Thanks!
        • 1. Re: onPress in class def?
          genotype Level 1
          Oh, the .fla file has the following code in the first frame:

          this.createTextField("status_txt", this.getNextHighestDepth(), 5,5,550,400);
          status_txt.scroll = true;
          status_txt.multiline = true;


          if (_level0.sound_files != undefined){
          html_vars_sound_files = _level0.sound_files;
          //status_txt.text = html_vars;
          var file_names_array:Array = html_vars_sound_files.split(",");
          } else {
          //this is temporary, these values should be coming from HTML
          _level0.sound_files = "4B.mp3,5A.mp3,2A.mp3,2B.mp3,3A.mp3,3B.mp3,4A.mp3";
          var file_names_array:Array = _level0.sound_files.split(",");
          }