Skip to main content
Known Participant
November 30, 2009
Answered

How can I load a .swf into all client?

  • November 30, 2009
  • 1 reply
  • 3652 views

Hi everybody...

I have to load a .swf file in all connected clients by pushing a button from another client.

Please, help me...

Emiliano.

    This topic has been closed for replies.
    Correct answer

    Hi, François...

    It still doesn't work...

    I installed, on a server in my domestic LAN, an Apache Web Server by downloading the file apache_2.2.13-win32-x86-no_ssl.msi from http://www.apache.org/....

    On the same server I have FMS3.

    - I replaced the rtmp:// protocol with http:// protocol.

    - When I type my URL in a browser, mySWF is Loaded in my web browser.

    -If I change the line:

    myLoader.load(new URLRequest("str"));

    with

    myLoader.load(new URLRequest("http://192.168.1.67/fms3/videocomm/BlocchiLogici.swf"));

    I have this error:

    *** Violazione della sicurezza sandbox ***
    SecurityDomain 'http://192.168.1.67/fms3/videocomm/BlocchiLogici.swf' ha cercato di accedere a un contesto incompatibile 'file:///C|/Documents%20and%20Settings/TOSHIBA%20SATELLITE/Desktop/Tesi%20Magistrale/Progetti/VideoComm/VideoComm.swf'

    but mySWF is Loaded....

    the other your questions...I don't know what to say: what is an embedded Apache? And what is "train movie"?

    Please, my friend, help me...

    Emiliano.



    Emiliano,

    What I see wrong in your code is lines like this :

    myLoader.load(new URLRequest("myParam"));

    If you do that you try to load on your server a file called myParam. Try this :

    myLoader.load(new URLRequest(myParam));

    So you will load the file name your server sent to your client.

    About the embeded Apache, when you install FMS the installer asks you if you want to install a bundled Apache server or not. If you do so you will find the Apache server inside FMS application files and it will be configured to proxy HTTP request to it. To be short, FMS listen on port HTTP (80) and Apache on the port 8134 (by default). When FMS receives an HTTP request it post it to Apache on the 8134 port on localhost and the Apache repsonse is sent back to the client. So if you need to load a SWF file on HTTP then this is how it is done.

    The "train movie" is a FLV video that you can see on a mini-site delivered with FMS installer. When you install it by default your server contains on it's base adress, port 80, a HTML page where you can see the FLV video. It is a lovely country side upview with an old train passing by. When you read the FMS installer that is how you can verify your FMS and Apache server are up and running.

    If you installed Apache after FMs you have to do 3 things :

    1. change you Apache httpd.conf to make it listen to an other port than 80 (let's say 8134). Just add the line "Listen 8134" where the httpd.conf mention the "Listen" parameter.
    2. change your FMS configuration to proxy the HTTP requests on your localhost, port 8134.
    3. then stop FMS, restart Apache and start FMS so they don't get into a listening port conflict.

    Check FMS documentation in the administrator guide to look where you can do that for FMS proxy configuration.

    Cheers,

    François

    1 reply

    November 30, 2009

    Use the broadcasting facility from your server

    =================================

    1- the client with the  button send a message to FMS indicating it it is time for all clients to load a SWF file. May be this client gives to FMS the SWF filename or may be the FMS knows it. Whatever.

    2- the FMS uses the application.broadcastMsg() method that will trigger a common method to all connected clients (this method must be defined on their active NetConnection.client object, let's call it "loadMySWF"). The broadcastMsg sends the SWF file URL to load like this :

         application.broadcastMsg("loadMySWF", null, myMovieUri);

    3- any connected client will receive the broadcast command and will load the SWF uri received as a parameter of their NetConnection.client.loadMySWF method.

    Other method

    ==========

    You can also use a SharedObject containing the SWF Uri as a property. Changing it on the server will trigger events on the clients to receive the Uri and load it.

    Hope it helps,

    IFZen



    Known Participant
    November 30, 2009

    Hi, IFZen...

    I wouldn't like to send a broadcast message...

    Might you explane the second method?

    Can I also use the Client.call() method?

    Thank you.

    Emiliano.

    November 30, 2009

    Yes you can use the Client.call but you will have to do it for every connected client you want to load the movie. So you will have to loop upon the application.clients array as it is shown in Adobe docs :

    for (i = 0; i < application.clients.length; i++){
        application.clients.call("serverUpdate");
    }

    It does the same thing as Broadcasting but inside your loop you can control if you have or not to call the method depending on your clients properties (access rights, status, etc).

    *******

    With SharedObjects you can define one object with a property called "SWFUri" initialized with the value "false". Let's assume clients cannot modify it if you don't want them to perturbe you server-side system.

    Then when you have something to load for the clients the server can change that property, assigning it for instance the SWF uri to load :

                soSWFLoader = SharedObject.get("SWFLoader", true);
               
    soSWFLoader.setProperty("SWFUri", "http://myserver.com/.../myfiletoload.swf");

    This modification will be send to any client connected to the shared-object. Reacting on this modification it will load the SWF file :

            mySO = SharedObject.getRemote("SWFLoader", myNetConnection, true); // true is for persistance

            mySO.addEventListener(SyncEvent.SYNC, eventSyncPartie);
           
    mySO.connect(myNetConnection);


            public function eventSyncPartie(event:SyncEvent):void {

                var p:String;

                for (p in this._so.data) {

                    switch (p) {

                        ...
                        case "SWFUri" :

                             if (this._so.data

    != "false") {

                                  // loading now SWF file

                             }

                             break;

                        ...

                    }
                }
            }