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(); 
var url:URLRequest = new URLRequest("filename.swf"); 

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);

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;


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;

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


About Ronnie Diaz

Ronnie Diaz is a software engineer and tech consultant. Ronnie started his career in front-end and back-end development for companies in ecommerce, service industries and remote education. This work transitioned from traditional desktop client-server applications through early cloud development. Software included human resource management and service technician workflows, online retail e-commerce and electronic ordering and fulfillment, IVR customer relational systems, and video streaming remote learning SCORM web applications. Hands on server experience and software performance optimization led to creation of a startup business focused on collocated data center services and continued experience with video streaming hardware and software. This led to a career in Amazon Prime Video where Ronnie is currently employed, building software and systems which stream live sports and events for millions of viewers around the world.

Posted on February 18, 2011, in Programming & Development and tagged , , , , , , , , . Bookmark the permalink. 2 Comments.

  1. This gives compile errors.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: