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
Posted on February 18, 2011, in Programming & Development and tagged adobe, cs5, fla, flash video, load fla, load swf, load swf from fla, swf, video. Bookmark the permalink. 2 Comments.
This gives compile errors.
What are the errors you received?