# AS3 & Red5

**URL:** <https://forum.kirupa.com/t/as3-red5/308449>\
**Category:** flash\
**Created:** [April 23, 2010, 5:29am UTC](https://forum.kirupa.com/t/as3-red5/308449 "2010-04-23T05:29:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrMaxMad](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@DrMaxMad](https://forum.kirupa.com/u/DrMaxMad)\
**Post date:** [April 23, 2010, 5:29am UTC](https://forum.kirupa.com/t/as3-red5/308449/1 "2010-04-23T05:29:50Z")

</div>

Hi,  
i am developing a service with red5 and AS3, the problem starts when i try to invoke a client side function from “connect” method, and it actually call the function before triggering the NET\_STATUS event, which creates a problem with my current scenario in which i am publishing live video stream, now when i connect to Red5 i get this runtime error…

///////////////////////////////// AS3 Error ///////////////////////////////////////////////////  
ArgumentError: Error #2126: NetConnection object must be connected.  
at [flash.net](http://flash.net)::NetStream/construct()  
at [flash.net](http://flash.net)::NetStream()  
at ChatApp/sendStream()  
at ChatApp/onUserID()  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at com.connections::NetConnectionClient/setUserID()  
#onConnectionStatusEvent# NetConnection.Connect.Success  
///////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////// Red5 Code //////////////////////////////////////////  
@Override  
public boolean connect(IConnection conn, IScope scope, Object[] params) {  
// Check if the user passed valid parameters.  
// if (params == null || params.length == 0) {  
// // NOTE: “rejectClient” terminates the execution of the current method!  
// rejectClient(“No username passed.”);  
// }

```
    // Call original method of parent class.
    if (!super.connect(conn, scope, params)) {
        return false;
    }

    //String username = params[0].toString();
    String uid = conn.getClient().getId();
    
    Client client = new Client();
    client.setUsername("user"+uid);
    client.setAge(100);
    client.setUid(uid);
    
    System.out.println(client.getUsername() + " : " + uid);
    
    // Register the user in the shared object.
    clientMgr.addClient(scope, client);
    
    return true;
}

@Override
public boolean roomConnect(IConnection conn, Object[] user)
{
    super.roomConnect(conn, null);
    // Notify client about unique id.
    ServiceUtils.invokeOnConnection(conn, "setUserID",
            new Object[] { uid });
    
    System.out.println("service invoked.....!");
    return true;
}

```

////////////////////////////////////////////////////////////////////////////////////////

can any one tell me how to call the function from client when the red5 application when it has already triggered NET\_STATUS event.

Regards
