3 Replies Latest reply on Apr 5, 2012 4:56 PM by Ned Murphy

    How do you start a function without a button?

    LuisRM Level 1

      I currently have an action that starts with a button click. But I want it to start on frame 1 automatically without a button. How do I need to edit my code to make this work correctly? It's a typewriter effect and I plan on exporting it out as a .MOV and importing it into Adobe Premiere. I also need to figure out how to get the background transparent if possible. Thanks in advance!


      Here is what I have.


      Button to start the action


      btn.onRelease = function()


      Typewriter function



      typewriter effect
      // clear the string
      //txt.text = "";
      // stop the page
      // the text string
      // use \n for line breaks
      var _txt:String = "“This is the text that will start after you press the button, but hopefully it will start automatically soon”";
      var _tmr:Number; // timer
      var _sec:Number = 62; // milliseconds till next letter
      var i:Number = 1;
      var l:Number = _txt.length;
      function TypeEffect() : Void
          if( i < l )
              txt.text = _txt.substr( 0, i );
          } else {
              txt.text = _txt;
              clearInterval( _tmr );
              trace("\t< FIN >");
          //trace( i );
      // call this function to start:
      function startTypeEffect() : Void
          trace("\t< START >");
          _tmr = setInterval( TypeEffect, _sec );