Inserting external swf "Widgets" into a Flex app

Hi.
I need to insert several external widgets into my Flex application. For example the Twitter flash widget and flickr slideshows widget.
Those widgets normally give you HTML code to insert in your HTML page, like:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" width="290" height="350" id="TwitterWidget" align="middle">
    <param name="allowScriptAccess" value="always" />
    <param name="allowFullScreen" value="false" />
    <param name="movie" value="http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#000000" />
    <param name="FlashVars" value="userID=xxxxxx&styleURL=http://static.twitter.com/flash/widgets/profile/smooth.xml">
    <embed src="http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf" quality="high" bgcolor="#000000" width="290" height="350" name="TwitterWidget" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="userID=xxxxxx&styleURL=http://static.twitter.com/flash/widgets/profile/smooth.xml"/>
</object>
I'm trying to achieve the same goal in my Flex application using the SWFLoader control, but I've got a lot of troubles starting with security issues, and although I just learned to pass the FlashVars values, I don't know how to pass the "<param" values.
public var twitterWidgetSrc:String = "http://static.twitter.com/flash/widgets/profile/TwitterWidget.swf?userID=xxxxxx&styleURL=h ttp://static.twitter.com/flash/widgets/profile/smooth.xml";
            <mx:SWFLoader
                id="twitterWidget"
                source="{twitterWidgetSrc}"
                height="290" width="350"
                init="setSecurity();">
            </mx:SWFLoader>
Is there an easier way to insert these widgets into my Flex application? or how can I complete the SWFLoader to achieve the same results?

I don't mean to disappoint you, but your Idea is impossible due to security violation
if you'll look inside this file http://static.twitter.com/crossdomain.xml
you'll probably find out that your host isn't listed there, so you will be not able to load any twitter stuff
Detailed info you could catch in here:
http://www.adobe.com/devnet/flashplayer/articles/flash_player_9_security.pdf
The only way to get the widget embed and working is through HTML

Similar Messages

  • Help Needed!! embeding a swf widget into a flash site

    Hi all.
    I am currently making a flash site for a band, and need to
    embed an external SWF widget into it.
    Its easy enough to embed it into HTML page, but idealy this
    site will endup a single SWF file, to make distribution onto the
    bands various pages (MYspace etc) easier.
    The code to embed in html is:
    <embed src="
    http://www.soundclick.com/player/V2/mp3player200.swf"
    width="200" height="140"
    flashvars="bandid=850463&playType=band&ext=1&testMode=0&autoplay=1"
    name="MP3PlayerBasic" type="application/x-shockwave-flash"
    wmode="transparent" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    />
    Some one told me it should be no probs to embed a swf with
    some sort of LoadMovie command, but he didnt have a qule about
    assigning flashvars to it.
    Any help here would ge greatly apreciated.
    Cheers.
    Sion

    I am listening to you and was letting you know that the code that I am trying to use is probably from an old forum. The code that Flash CS4 cranks out is about 10 pages long which seems a little much just to import an .swf with a transparent background. I don't imagine CS6 would be much shorter.
    From what I gathered, the html file checks to see what version of Flash you're using as well as what browser. The code for that is insane in my opinion and I am trying to keep my html file for my homepage rather small. I had no problem importing this in DW with a transparent background (when I was using DW) but am using Komodo Edit as my HTML editor now as it didn't come with Production Premium that I just got.
    If you know the correct (newer) code, that would import an .swf with a transparency, that would be most be useful. If not I guess I'll just wait for someone to reply that does.
    I will try to extract the code from the CS4 HTML file and use that, but did already try it once and it didn't work. If all else fails, I'll just download a trial version of DW and/or Flash CS6 and see if I can figure out how I did it on a website I developed a couple years ago (that I lost the files from in a HD crash).

  • Is it possible to Load External SWF files into Flex Mobile projects?

    Hi Guys,
    I'm trying to load an external asset in this cse (a SWF file) into my flex project (Apple IOS IPAD), don't get any luck. Can any one suggest a solution ?

    In Apple's words, "No interpreted code may be downloaded or used in an Application except for code that is interpreted and run by Apple's Documented APIs and built-in interpreter(s)".
    Hence external swfs cannot be loaded in iOS.

  • How to insert a swf file in to flex..

                   hi all
    i'm trying to insert a swf file in my flex. I'm trying to insert a help manual e-book to my flex application,
    i dont have any idea in flex... i have some 1 month experiance in flex...
    so plzzz help me...

    Are you just looking to load an external swf into your flex application? Are there any requirements where the external swf has to be stored like on a different domain or can it be packaged with your Flex app?

  • Can I load a swf into my Flex app that loads other swf's?

    The code below loads an AS2 swf into my Flex mobile for IOS app and it works.  If that AS2 swf has like a circle in it that runs across the stage, it loads and displays properly when run in FlashBuilder.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                     xmlns:s="library://ns.adobe.com/flex/spark"
                                     xmlns:mx="library://ns.adobe.com/flex/mx"
                                     initialize="init()">
              <fx:Script>
                        <![CDATA[
                                  import mx.core.UIComponent;
                                  private var request:URLRequest = new URLRequest("http://PATH_TO_AS2_SWF");
                                  private var loader:Loader = new Loader();
                                  private var myComponent:UIComponent = new UIComponent; 
                                  private function init():void{
                                            myComponent.percentHeight = 100;
                                            myComponent.percentWidth = 100;
                                            loader.load(request);
                                            myComponent.addChild(loader);
                                            player.addElement(myComponent);
                        ]]>
              </fx:Script>
              <s:Group id="player"
                                   height="100%" width="100%"/>
    </s:Application>
    But if that AS2 swf loads other swf's, they don't load or display.  My FlashBuilder debugger reports no errors or security sand box violations.   I'm using the most elemental code in my AS2 swf so as to not cause problems.  This is it in its entirety:
    this.onLoad = function(){
              _root.loadMovie("http://[PATH_TO_REMOTE_SWF]");
    The paths to the remote content are fine because swf's load and display fine from AS2 swf when run on it's own - not embedded in Flex app.  They also load and run fine if I cut out the AS2 swf and access directly from my Flex code.  So I know there isn't a path issue.  More likely not accessing the right layer in the AS2 swf from Flex or something.  Or maybe security sandbox violation but I don't see anything reported in the FlashBuilder debug console.  When run console just reports:
    [SWF] SwfMobile.swf - 2,639,761 bytes after decompression
    [SWF] assets/swf/AS2.swf - 1,470 bytes after decompression
    Is there something inherently wrong with loading swf's that load other things?  Even if I have the AS2 swf load jpgs they don't load so the format of the target content at the end of the chain doesn't seem to be the issue.  Just the act of embedding a swf that loads other things seems to be the problem.

    Ah, yes. Using an AVM1 SWF could prove difficult...
    I'm going on about 3 hours of sleep at the moment, but let me toss out a few thoughts I have and hopefully something will stick...
    Ok, so my first thought what to try and cast the loaded content as a MovieClip and call methods on that, but the fact they are AVM1 throws that out the window.
    That leaves LocalConnection, as you mentioned. But this would require you to have code on the receiving end to handle the connection... no good either.
    But what if you created a "bridge" in AS2 that holds all the code for the receiving end of LocalConnection (or has the control logic itself, perhaps even eliminating the need for LocalConnection all together!). I think maybe this is what you were trying to do already by loading a SWF into a SWF? Well instead of loading your bridge at runtime, what if you statically linked it into your project as a class?
    *a few moments later*
    Well it looks like you can in fact link in a a symbol created for AVM1, but it will only come in as a SpriteAsset, and will not include any custom code (which makes sense, since they use entirely different class constructs).
    To do the test, I created a symbol exported for actionscript (AS2/Flash8), then linked it in with a CSS style embed. I then instantiated the class and called describeType on it.
    So in summery, it looks like calling custom code on the bridge is out (I did not test this extensively, that was just my first impression with this simple test). However, if you may be able to perform the actions you need by attempting to cast the loaded content into something AVM2 can recognize. Apparently it does this automatically when linked in statically, so maybe there is something there worth looking into... mainly, can you do what you need using only the base class and no custom code?
    Keep me posted!

  • Loading an external webpage into the Flex app

    Is there a way to load an external webpage into a Flex application. I only need to show a portion of the webpage not the entire page. For ex: Take the http://www.cnn.com main page. I only want to show the latest news column containing the bullted list of the news and not the entire page.
    Thanks in advance.

    You could use Flex I Frame component. Here is the link
    http://code.google.com/p/flex-iframe/

  • FAQ: How do I load an external SWF file into a parent SWF file?

    A ton of Flash users visit Adobe’s we site every month wondering  about how to load an external SWF file from within another SWF.
    Adobe's own TechNote on the subject attempts to answer the basic question, along with some common follow-up questions, including:
    How do I load more than one SWF?
    How do I load a SWF into a specific location in the display list?
    How do I resize the loaded SWF?
    How do I set its X and Y location?
    Here are some additional resources that elaborate on loading content and on working with the display list:
    Sample files for the above TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
    Help > AS3 Developer’s Guide > Loading an external SWF file
    Help > AS3 Developer’s Guide > Loading display content dynamically
    Loading multiple external SWFs within a main SWF – CreativeCow.net forums
    Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
    Video tutorial: Preloading in ActionScript 3.0.  By Lee Brimelow. A slightly more complicated example, showing how to  make the parent SWF display information about the progress of loading  the external SWF.
    Tutorial: Loading and unloading SWFs - FlashAndMath.com
    This article provides several examples of how to communicate between a parent SWF file and the loaded SWF:
    SWF to SWF Communcation via ActionScript 3.0 (by kglad)

    quote:
    Originally posted by:
    NedWebs
    You now seem to want to get rid of the swf once it has loaded
    and played itself thru. To do that you would need to have something
    in the swf itself that triggers its removal in its last frame. The
    following might work...
    MovieClip(this.parent).removeChild(this);
    Unfortunately I couldn't get this to work. I placed it on the
    last frame of the SWF to be called - is that right?
    I am not sure I am doing it correctly...

  • Loading external SWF's into an SWF Loader as3 style?

    Hi,
    I've recently made the switch from as2 to as3 and am still struggling to get my head around one aspect in particular. I've managed to load one external swf into a blank file via the script
    import LoadDisplayObject;
    var loader:LoadDisplayObject = new LoadDisplayObject("button_01.swf", true);
    loader.addEventListener("displayObjectLoaded", onComplete, false, 0, true);
    addChild(loader);
    function onComplete(evt:Event):void {
         trace("loaded complete received");
         loader.scaleX = loader.scaleY = .75;
    .....however I'm struggling with the script to make a swfs load into a space when one of my 3 buttons is clicked....
    My page currently has three buttons (button_01, button_02 and button_03) and in a local folder three separate swfs with the same names which I wish to load in, when the appropriate button is pressed. 
    I have managed to get them to load in using a tutorial...however they load over the top of each over...far from ideal. From research on the internet I've found a range of different script...but I just can’t find anywhere I can find script to make this work..hence why I have turned to here.
    Any help much appreciated...thanks in advance.

    Hi,
    Just throught I would let you know that I've manged to get this to work this morning. Changed the script slightly and used a different method of:
    var home:MovieClip = this;
    function butt1Click(evt:MouseEvent):void {
        var ldr:Loader = new Loader();
        ldr.load(new URLRequest("button_01.swf"));
        ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
    function butt2Click(evt:MouseEvent):void {
        var ldr:Loader = new Loader();
        ldr.load(new URLRequest("button_02.swf"));
        ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
    function butt3Click(evt:MouseEvent):void {
        var ldr:Loader = new Loader();
        ldr.load(new URLRequest("button_03.swf"));
        ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
    function loaded(evt: Event):void {
        if(contentClip.numChildren > 0){
            contentClip.removeChildAt(0);
        contentClip.addChild(evt.target.content);
    button_01.addEventListener(MouseEvent.MOUSE_UP, butt1Click);
    button_02.addEventListener(MouseEvent.MOUSE_UP, butt2Click);
    button_03.addEventListener(MouseEvent.MOUSE_UP, butt3Click);
    seems to work well. Only small question is if I want one page to load automatically upon opening...how do I alter the script to do this??? Thanks

  • How to detect the end of an external swf loaded into a container

    Hi,
    I'm having trouble finding a solution for this problem, can somebody help me?
    I have a main swf that will load external swfs into a container. I need to detect the end of the loaded external swf in order to start to load and play a new one into the same container.
    The problem is that i do not know what the length of the external swfs will be, and will have no control over the development of them, so i cannot place a variable at the end of their animation which would allow me to detect from the main movie its end.
    I also cannot rely on the _totalFrames property because the loaded swf might not have all the animation inside its main timeline.
    Is there any way to achieve this goal?
    Thx

    Ok... Its as i thought... unfortunatly...
    Gonna mark your latest post again as possible solution, just in case someone comes with any sort of out of the box thing...
    Thx for your help Kglad

  • Insert an swf file into another Flash file

    Hi,
    I'm a newbie to flash trying to insert an SWF flash file (a game) into another Flash file. However, when I import the swf file into the library and drag it onto the frame (and insert the stop(); command onto the frame action to stop it playing the whole movie), the SWF file plays constantly, ignoring all the actionscript and button commands in the game SWF file.
    When I try inserting it using the Window component, the game SWF refuses to play at all - it just stops (clicking buttons in the game work, but it goes-to-and-stops instead of go-to-and-play like it's supposed to do). The only other component I could find was called "Loader". Using this doesn't work either, it won't play any of the animation, just like using the "Window" component
    When the game SWF is played by itself (by just double-clicking to open it from Windows Explorer or embedding it in a web page), it works fine.
    Any help how to do this would be appreciated.
    Thanks.

    Hi,
    I'm posting in this thread because my problem seems similar but may be not...
    In my first swf, I'm loading a second swf via loadClip().
    My second swf works well alone but when I try to integrate itself in my first swf I'm losing my events. My events only works on my first swf.
    I'v tried your trick with _lockroot but he doesn't work for me too.
    Is someone have an idea to help me ?
    Thx
    My code is really basic
    First swf:
            var mcloader:MovieClipLoader = new MovieClipLoader();
            var listener:Object = new Object();
            listener.onLoadInit = function (mc:MovieClip){
                main_obj.__preloader.die();
                obj[funct](target_mc, param);
            mcloader.addListener(listener);
            mcloader.loadClip(file_name, __loader);
    Second swf:
        var box:MovieClip = this.createEmptyMovieClip("box"+depth, this.getNextHighestDepth());
        //Draw box
        drawBox(...);
        // Event on Box, Change Alpha and show arrow or not
        box.onRollOver = function() {
            drawBox(...);

  • Loading external swf`s into main page automatically after 300 frames

    hi guys
    i have a main file called DEMAND.fla that has a loader placeholder/positioner thingy in it with the instance name "loader_mc_james"
    when the page opens it uses the code below to load in an external swf named demand_001.swf. to the placeholder location
    loader_mc_james.loadMovie("demand_001.swf");
    now at the moment i have 6 external files, demand_001, demand_002, demand_003 etc and use 6 individual buttons located on the DEMAND.fla page that the viewer clicks on to load each page as required, it all works fine and I happy with it.
    In the future however i would like demand_001.swf to load up and when it gets to frame 300 autmatically load up demand_002.swf and so on.
    MY QUESTION IS: What code would i stick at frame 300 to get that to happen?
    Any advice would be appreciated.
    Ps, it would also good if all the other exteranl files were loading into memory in the background as soon as the inital page is opened.
    you can see what i have at the moment here
    http://www.omega-completion.com/downhole_demand_activated_technology.html

    What you could do is have the DEMAND file include a fiunction that manages the loading and have your loaded files call that function.  You could either have a variable that you increment to modify the name of the file to load, or just pass the name of the file to load in the function call.  For the latter of the two your DEMAND function to load the files could be something like...
    function loadDemands(swfFile){
         loader_mc_james.loadMovie(swfFile);
    loadDemands("demand_001.swf"); // to start things off
    Then, in frame 300 of the 001 file you can have...
    _root.loadDemands("demand_002.swf");
    If you prefer the first option, then your DEMAND file would do the work of determining who gets loaded next and your loaded files would call the function without the argument.  Something along the lines of...
    var currentSWF = 1;
    function loadDemands(swfFile){
         loader_mc_james.loadMovie("demand_00"+currentSWF+".swf");
         currentSWF += 1;
    loadDemands(); // to start things off
    Then, in frame 300 of the files you can have...
    _root.loadDemands();
    (NOTE: if _root fails, try _level0 )

  • Inserting flash .swf file into template

    I want to insert a flash file into the right sidebar to appear on all pages of the website.  I know I need to do this via the template.  I think I need to click in the insertion point, then copy the code (make sure the files are in the correct location).   I've done this before with galleries ect..  but not in DW and not from a template.  What's a little confusing is there are 3 templates.  The first is in it's own folder (design template), the other two (theme 01 design & theme 01 design from template) are in the root folder, but the theme 01 design one doesn't seem to be changeale.  Which template should I be working with?
    www.wranglergirl.net
    Thanks from a newbie!  Amy

    Are each of these 'templates' actually DW templates (i.e., are they named with a *.dwt extension)?  If so, then they must all be located within the Templates folder at the root level of the site - it doesn't sound like that is the case.  Also, why do you need three templates?  Finally, which version of DW are you using?  It's likely that you will have to make any links to your Flash element with ROOT relative links to be successful.

  • How to correctly load an external swf file into iosAir app? I'm getting blank screen.

    So this code works flawlesly on Air for Android, it even works fine when I test the movie in Flash, but once I export it, I'm getting a blank screen. I made an swf with a square and withotu any code, and flash still fails to load it. It's weird cause everything works fine when I use the interpreter debugging option, but when I switch to standard debugging the blank screen appears on my ipad. I've read somewhere that it's caused by the way flash saves the link to external files. Thus after the file is compiled Flash fails to find the prefiously added files, which results in a blank screen. There's clearly something wrong with how the process of compiling the application.
    Tried this:
    var Xpos:Number = 0;
    var Ypos:Number = 0;
    var loader:Loader = new Loader();
    var link:URLRequest = new URLRequest("Untitled-1.swf");
    loader.load(link);
    addChild(loader);
    And this:
    var ldr:Loader = new Loader();
    ldr.load(new URLRequest("Untitled-1.swf"));
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded, false, 0, true);
    function loaded(event:Event):void {
    addChild(event.target.content);
    But nothing works. I'm still getting a blank screen. Is there any way to add the swf file manually into the descriptor file cause flash most likely messes it up? I don't really want to use through command line.

    Read this article, especially the bit about loadercontext and currentdomain:
    http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air- apps-on-ios/

  • Is it possible to embed an external control (eg ActiveX) into a Flex app?

    I'd like to build an app, and Flex seems to be a good option.
    The Flex stuff would be hosted in an application within the Adobe
    ActiveX Flash Player. The communication between the hosting
    application and the Flex application would be possible via the
    ExternalInterface. However, I'd need to embed a special control (in
    fact a word processor) in one of the panels of the Flex
    application. Is there a way to do it? It could be a browser window
    as well.
    Thx

    I am new to flex myself but as musch as i know and if i have
    rightly understood your problem than if the control is compatible
    to flex ie: written in action script version supported by the flex
    version you are using than you can create a library project and add
    the action script code to it. now add the flex library project or
    the resulting .SWC file to your original project's library build
    path. your new control will apear in the custom controls
    list

  • Inserting externally purchased code into Muse.

    I purchased code that I would like to use in my site. How do I use it with Muse? I understand how to place HTML, but right now I have CSS and JQuery files. Is there any way to get it in there?

    It's hard to give a useful answer to that question. There's a wide variety of HTML widgets out there with lots of different requirements...
    Generally speaking, CSS files usually contain styling info, to control how some HTML elements look.
    JS files are scripts that usually attach behavior to certain HTML elements.
    Usually you'd also have some HTML to insert so the CSS has something to style and the JS has something to attach behavior to.
    Muse has a few features that may help you integrate this fabulous thing into your Muse layout.
    1) Insert HTML allows you to insert a bit of HTML which Muse will export along with the rest of your page.
    2) The page properties dialog metadata pane allows you to insert HTML code into the <head> of the exported HTML page.
    3) The 'Add files for upload' menu item allows you to tell Muse to upload additional files to your website. They'll be uploaded into a folder named 'assets'.
    Depending on what you have, you might be able to use some of these features to get your wonderous thing into Muse without editing any of Muse's output.
    If these features aren't sufficient for your use case, you may have to edit the exported HTML as suggested by iamDK. Note that if you do this, you'll have to re-edit the exported HTML every time you export/publish/ftp upload from Muse, as Muse does not preserve any edits made to the generated HTML.

Maybe you are looking for