Skip to main content
Participant
January 9, 2007
Question

sharing a netconnection or netstream between multiple swf

  • January 9, 2007
  • 1 reply
  • 397 views
Hi,

I posted this question in the actionscript forum, but couldn't get an answer.

Is it possible to create a NetConnection in one swf and access/use that object in another swf file on the same page?

My goal is to have multiple media components on a web page that the user could enable or disable. I don't want to have to create a new NetConnection for each one, as this is expensive.

According to the docs, LocalConnection can be used to pass objects between two swf files.

Is it possible to send a NetConnection or NetStream object from one swf file to another to redirect a connection / stream without creating a second one? I tried doing this with arbitrary objects, and it works. But when I try to pass in a NetConnection object, it always shows up as undefined on the receiving end.

Thanks.
    This topic has been closed for replies.

    1 reply

    January 10, 2007
    You can let the "slave" SWFs talk to the "master" SWF and let the master "SWF" make calls to the FMS server.

    The Localconnection Object will do the job for you.

    1. set up a working LC between 2 SWFs
    2. make on each SWF a function that fills an inputtext field with a string that you passed as an argument
    3. make a button that calls the function on the LC in your targer SWF
    4. test that this works

    5. make a netconnection to your FMS in your master SWF
    6. define a function in your FMS serversided code that does a trace so you can see that that function is being called from your Flash client
    7. Use the Flash Media Console to connect to your server , your application and your instance (if you use an instance of your application)
    8. make a button in your master SWF and let it call the function
    9. make sure the serversided function on your FMS server is being called and see that your argument is being traced in the FMS console
    10. define a localconnection function in your master SWF that calls the serversided-function on your FMS
    11. call from your slave-FMS the LC-function in your master-SWF.
    12. Check with your FMS Console if the function executes

    Et voila. You "share" 1 netconnection with more than one SWF now.
    Participant
    February 7, 2007
    Hi, I'm a beginner in FMS and I'm trying to share a Netconnection object between some SWF. I've all files programmed and they work independently, but now I want to mix them. I've read FMS_Developer solution and it works correctly, but if I have to adapt all my code to this and I will have a lot of work!
    I only want to know if it's impossible to pass a NetConnection object that in the slave SWF will be a reference to Master SWF object? If it could be possible I would be very very happy.
    Thanks a lot!