Blog Archives

Run SWF Files from an EXE

SWF/Flash files may be embedded into an executable a number of ways, using:

Adobe Flash Platform
Adobe Air
MDM Zinc
Northcode SWF Studio

Adobe Flash and Air refer to the published executable as projectors, and both can be packaged using the Adobe Flash Platform or Air.

Zinc and SWF Studio are both 3rd party products which offer similar functionality. In my opinion, Zinc is the greater of the two products, as it offers support for Windows, Mac and Linux! It also has an API/framework for utilizing WinForms functionality such as launching modal form windows using actionscript. The API is packaged into the executable, so a clean standalone file is still all that is needed for deployment.

SWF Studio is more of an “out of the box” product, which functions as is for what it is needed for. Some may favor it due to its simplicity and ease of user interface, which on the surface seems to have a bit more features.

Ultimately, I went with Adobe Air in my particular scenario, which was definitely the most complex of the solutions, but provided the best compatibility by far (obviously) and the best one to get to work with SWF files that wrapped other SWF files multiple layers deep.

Brief addendum:
Initially I developed a custom .Net solution which loaded the SWF file inside of a form, (webbrowser object in winforms or frame in wcf) but the dependency on .Net and furthermore, Mono, in Mac/Linux systems posed as a problem since the delivery of the player needed to fit on CD/DVD alongside the videos, with very little space to spare for adding in additonal frameworks.

References
Adobe Flash Platform, http://www.adobe.com/flashplatform/
Adobe Air, http://www.adobe.com/products/air/
MDM Zinc, http://www.multidmedia.com/software/zinc/
Northcode SWF Studio, http://www.northcode.com/
Mono-Project, http://www.mono-project.com/Main_Page

Load SWF from Fla file CS5

The title of this blog was my initial search in google upon looking for a way to load and play an external SWF file inside a new FLA project file.

In AS2, I recalled this was easily achieved using MovieClip, however, Adobe has deprecated this functionality in favor of the newer AS3 concept of “loader” objects.

See syntax below and references for helpful links:

var myLoader:Loader = new Loader(); 
addChild(myLoader); 
var url:URLRequest = new URLRequest("filename.swf"); 
myLoader.load(url); 

Slightly less orthodox, but code below works also. Note URLRequest can point to a local file or a remote SWF file on the web.

swfLoader = new Loader();
swfLoader.load(new URLRequest("filename.swf);
addchild(swfLoader); 

Can also be done using UI Loader:

import fl.containers.UILoader;

var myUILoader:UILoader = new UILoader();
myUILoader.source = "Rich Investor.swf";
myUILoader.move(0, 0);
myUILoader.scaleContent = false;

addChild(myUILoader);

Using Adobe Air in publish settings:

   package {

   import flash.display.Sprite;
    import flash.html.HTMLLoader;
    import flash.net.URLRequest;

    public class HTMLLoaderExample extends Sprite
    {
        public function HTMLLoaderExample()
        {
            var html:HTMLLoader = new HTMLLoader();
            var urlReq:URLRequest = new URLRequest("Rich Investor.htm");
            html.width = stage.stageWidth;
            html.height = stage.stageHeight;
            html.load(urlReq); 
            addChild(html);
        }
    }
   }

References
Load external SWF files into Flash Player, http://kb2.adobe.com/cps/141/tn_14190.html
Creating new MovieClips in ActionScript 3.0, http://blogs.adobe.com/pdehaan/2006/07/creating_new_movieclips_in_act.html
Loader vs MovieClip http://forums.adobe.com/thread/434686?tstart=1
Loader vs. UILoader, http://www.kirupa.com/forum/showthread.php?t=283920
Getting Started with AS3 and Flash CS3, http://www.actionscript.org/resources/articles/636/2/Getting-Started-With-AS3-and-Flash-CS3/Page2.html
UI Loader, http://www.gotoandlearnforum.com/viewtopic.php?t=17761
MovieClip (object) http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary505.html
Loading a .swf file into a .fla file, http://www.flashmove.com/forum/showthread.php?t=9318
Add video to Flash, http://help.adobe.com/en_US/flash/cs/using/WSb03e830bd6f770ee-70a39d612436d472f4-7ff8.html
Externally loading SWF into movie clip, http://www.actionscript.org/forums/showthread.php3?t=156851