Can I reuse ActionScript 3 NetConnection?

this is probably a noob question, but since I'm new to Flash and AS3, here it goes ...

Is there any way to reuse AS3 NetConnection?

I am trying to create an AMFPHP class that handles a connection, so I can reuse this initial connection when I want to make an AMFPHP method call.

Here is my code so far,

package com.utils
{
    public class amfphp 
    {
        private var gateway:String = "http://localhost/amfphp/gateway.php";
        private var connection:NetConnection = new NetConnection;

        private function con(gate:String, con:NetConnection):void {
            //connect to the gateway file
            con.connect(gate);
            return con;
        }
    }
}

Thanx in advance!

+3
source share
1 answer

That's right, your solution is workable. One small thing that I am saying is because you said that you are new to as3. Your function cannot return with the connection object, because the return value is set to void.

All the best.

Tamash

+2

All Articles