1 Reply Latest reply on Oct 9, 2006 7:30 AM by NSurveyor

    Injecting ActionScript into .fla/.swf through command-line

    pete_dude
      Hi!

      I have a 4-line ActionScript that I'm trying to inject into .fla / .swf file on compile-time. The script basically reports to web-page JavaScript the progress (position in miliseconds) of the internal .flv file. The AS is this:

      setInterval(callJSWithPlayTime, 1000);
      function callJSWithPlayTime() {
      getURL("javascript:window.reportPlayTime(" + getTimer() + ");");
      }

      When I edit the .fla manually with Flash 8, I can easily create a layer and put this script on the first frame and then compile the .swf. However, I want this script-injection process to happen automatically through a commad-line. So given bunch (say thousands) of .fla files that don't contain my script, I want to either inject my script into the .fla files or perhaps just tell the command-line compiler tool (mxmlc.exe) to merge in my script on compile-time.

      What's the best way to do this? I heard there is a way to isolate ActionScript programs from the .fla files but it seems this requires .fla to be first modified so that it includes reference to external AS file. I'm really trying to do this all without even needing to open the Flash8 editor.

      Any pointers are appriciated. Thanks.

      Second side-line question: will getTimer() function return to me the Flash movie play time or will it return the internal FLV movie play-time? I really care about the latter. I'm worried that if there are multiple movies within the .fla or if user say pauses the movie, I will not be getting the accurate time reading there.

      Thanks again
      Pete