How to replace links in existing SWF flash movie in ActionScript using SWF Scout library

Submitted by eLenka on 6 July, 2011 - 12:42

SWF Scout library is capable of replacing text in actionscript string variables and values in existing flash movies. For example, this can be used to replace all links from one URL to another.

In this example we will take existing flash movie with button and will replace all links to www.myurl.com with  www.bytescout.com links.

IMPORTANT: clicking on button may not work in some browsers like Internet Explorer as they forbid opening a links in flash movies by default.

Input flash movie (ButtonWithURL.swf) with button (with ActionScript assigned to "press" event) and text edit (before replacement):

Source code - 1) replace link www.myurl.com in ActionScript with www.bytescout.com; 2) replacing www.myurl.com with www.bytescout.com in all editable text objects:

Set Movie = CreateObject("SWFScout.FlashMovie")
 
Movie.InitLibrary "demo","demo"
 
Movie.BeginMovieFromTemplate "PARSEACTIONS://ButtonWithURL.swf",true
 
Movie.AddTemplateRule_Text "www.myurl.com","www.bytescout.com (replaced)",false
 Movie.AddTemplateRule_Text "VARINACTIONSCRIPT://http://www.myurl.com","http://bytescout.com",true
 i = Movie.ProcessTemplateRules
 
Movie.EndMovie
 
Movie.SaveToFile "ButtonWithURL_ReplacedURL.swf"

Output flash movie (ButtonWithURL_ReplacedURL.swf):

Download source code: