Page 1 of 2

Modifying the RedBox examples

Posted: 01 May 2009, 17:22
by JarochoCity
How can I modify the RedBox examples?

is there a .FLA ? or how can i modify it?

I want the .FLA without the SmartFoxBits

Posted: 02 May 2009, 09:46
by Bax
Are you talking about AS2 or AS3 examples?
AS3 examples can be found in the latest SmartFoxServer download package, and are distributed as Flex Builder project source files.
AS2 examples can be downloaded from this link: the package contains the FLA files. These examples have been built using the SmartFoxBits. The RedBox requires the Connector only, which you can use even if you don't want to use the other Bits.

Withouth SmatfoxBits

Posted: 02 May 2009, 14:29
by JarochoCity
Yeah, I'm talking about the AS2

But I don't want to use the smartfox bits, how can use those examples, using just the connector as you said, but not using the other smartfoxbits.

This is my code, but nothing happens:

Code: Select all

import it.gotoandplay.smartfoxserver.*
import it.gotoandplay.smartfoxbits.events.*

stop()

var zone:String = "SmartChatAV"
var myUserName:String = "Jack"
var SFSEvent:SmartFoxClient = connector_mc.connection

connector_mc.addEventListener(SFSEvent.onConnection, onConnectionHandler)
connector_mc.addEventListener(SFSEvent.onLogin, Delegate.create(this, onLogin))

function onConnectionHandler(evt:SFSEvent):Void
{
   trace("Response");
   if (evt.params.success)
   {
      trace("Great, successfully connected!")       
     
      // Log into the "simpleChat" zone without using the LoginBox component
      smartFox.login(zone, myUserName)
   }
}

function onLogin(evt:SFSEvent):Void
{
   var response:Object = evt.params.resObj
   
   if (response.success)
      gotoAndStop("chat")
}


It doesn't trace anything, it only trace this:


Code: Select all

[Sending]: <msg t='sys'><body action='verChk' r='0'><ver v='153' /></body></msg>

[Received]: <cross-domain-policy><allow-access-from domain="*" to-ports="9339" /></cross-domain-policy>
[Received]: <msg t="sys"><body action="apiOK" r="0" /></msg>


I can see it doesn't call the onConnectionHandler function, because I don't see the "Response" trace.

I want this using AS2.

Posted: 02 May 2009, 22:34
by Bax
It seems the Connector isn't trying to connect... is the autoConnect parameter set to true?

yeah

Posted: 02 May 2009, 22:36
by JarochoCity
yeah, its set to true.

and i can see it connects, because it goes green and it says CONNECTED, but it doesnt handle the "SFSEvent.onConnection" function.

Posted: 02 May 2009, 22:49
by Bax
Maybe you are receiving the event before the event listener is received. Try turning off the autoConnect, and call the Connector.connect method after adding your listeners.

tried before

Posted: 03 May 2009, 00:48
by JarochoCity
I have also tried that, and once again, nothing happened.

So what should i do?

Posted: 04 May 2009, 06:51
by Bax
Send us your fla, so we can give it a look.

hey

Posted: 05 May 2009, 16:35
by JarochoCity
hey, ive send you the file through PM!

Posted: 06 May 2009, 06:35
by Bax
You called the Connector instance on the stage mc_connector, but in the code you add listeners to connector_mc.

another problem

Posted: 06 May 2009, 19:23
by JarochoCity
Now it shows me this:

Code: Select all

SmartFoxClient.myUserId and/or SmartFoxClient.myUserName properties not set: in case of custom login they must be set manually to the actual server values


What can I do?

Posted: 06 May 2009, 20:58
by Bax
When using a regular login, the client will handle the login response via the onLogin event handler. Behind the scenes the client API will assign the SmartFoxClient.myUserName and SmartFoxClient.myUserId properties.

When using a custom login the response is sent back to the client via the extension and it is handled in the onExtensionResponse handler. In this case the myUserName and myUserId properties ARE NOT populated auto-magically, so you will need to do it manually.

In your custom login response from server to client also send the username and smartfoxserver id, and assign those properties manually.

hey

Posted: 07 May 2009, 00:20
by JarochoCity
I have stablished the user and id, with the custom login and nothing happens :S

Still getting the same error.

I stablished the id and username this way on the onExtensionResponse:

Code: Select all

 _global.myName = resObj.name
            smartfox.myUserName = _global.myName;
            smartfox.myUserId = resObj.id;
            trace(smartfox.myUserId);
                gotoAndStop("chat")


And its working because I trace it.

But if that is not the way to set the user and id, how can I do it?

Posted: 07 May 2009, 05:54
by Bax
The error you get is thrown if those properties are not set when the AVCastManager instance is created. So make sure you do not create it before the onExtensionResponse handler is called.
In case you already do this, can you please send via PM a fully working example? I can't compile the fla file you sent previously, due to missing classes.

hey

Posted: 07 May 2009, 14:24
by JarochoCity
PM sent, thank you!