Cannot import smartfoxbits.events

Everything about the SmartFoxBits UI Components for SmartFoxServer 1.x. Post your questions, suggestions and bug reports.

Moderators: Lapo, Bax

Rashomon
Posts: 72
Joined: 11 Aug 2010, 19:48

Cannot import smartfoxbits.events

Postby Rashomon » 09 Jun 2011, 20:48

(In Flash CS5 Professional)

I'm trying to override loginBox.loginButton, as described here: http://www.smartfoxserver.com/bits/docs/as3Flash_SFS2X/html/com_smartfoxserver_smartfoxbits_bits_LoginBox.html. Specifically, "If you need to override the default behaviour (execute login) when the login button is clicked, you can register to the BitEvent.LOGIN_CLICK event..."

I followed the example, and I can create the loginBox just fine:

Code: Select all

import com.smartfoxserver.smartfoxbits.bits.LoginBox;

// Create LoginBox instance
var loginBox:LoginBox = new LoginBox();

// Set SmartFoxServer zone to connect to
loginBox.zone = "simpleChat";

// Add LoginBox instance to stage
addChild(loginBox);


However, I cannot figure out how to import com.smartfoxserver.smartfoxbits.events so I can register my eventlistener. Here's what I have:

Code: Select all

import it.gotoandplay.smartfoxbits.events.*;
// loginBox.loginButton.addEventListener(BitEvent.LOGIN_CLICK, onLoginClick);


When I try to run, I get - "Definition it.gotoandplay.smartfoxbits.events could not be found."

I think I'm missing something basic in the setup.

I downloaded the Bits package and ran the .mxp file.
I dragged the LoginBox from my components window into my library.
In my Actionscript settings Source Path, I added a path to "c:\SmartfoxBits\Flash\SmartfoxServer_1"
I added the same path for my Library Path.
I also found "SmartFoxBits_BasePack_CE.swc", so I added a link to that in my Library Path.

Still... no luck. Where do I need to place my Bits library, and how should I link to it???
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 10 Jun 2011, 07:52

Which version of SFS are you using?
If you use SFS 1 (as the fact that you posted this message in this forum suggests), then you have to import it.gotoandplay.smartfoxbits.events.*
But if you are using SFS2X, then the package has changed and you have to import
com.smartfoxserver.smartfoxbits.events.*
Paolo Bax
The SmartFoxServer Team
Rashomon
Posts: 72
Joined: 11 Aug 2010, 19:48

Postby Rashomon » 10 Jun 2011, 11:48

Thanks for the quick reply.

Yes, I'm using SFS 1. I am also importing it.gotoandplay.smartfoxbits.events.*

Do you have any other suggestions?

You can download my simple example here: BitsEvents.zip
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 10 Jun 2011, 11:54

I'm sorry, I made a mistake. I reviewed the documentation, and the right package is com.smartfoxserver.smartfoxbits.events for any version.
Just make sure you are using the latest version of the Bits available (download the trial version from the website or the download link if you purchased a license).
Paolo Bax
The SmartFoxServer Team
Rashomon
Posts: 72
Joined: 11 Aug 2010, 19:48

Postby Rashomon » 10 Jun 2011, 16:17

That did it! :)

I removed and reinstalled SmartFoxBits. I think the real problem was the name of the library that I was trying to import.

Previously, I was using the it.gotoandplay prefix, which I found here: Package it.gotoandplay.smartfoxbits.events. However, as you pointed out, I should use com.smartfoxserver.smartfoxbits.events.*. (I also needed to include the .*)

I added a Connector and LoginBox, hooked them up, and they work.

For others working with Bits events, here's how I set up my listener and handler:

Code: Select all

import com.smartfoxserver.smartfoxbits.events.*

loginBox.addEventListener(BitEvent.LOGIN_CLICK, onLoginClickHandler);
function onLoginClickHandler(e:BitEvent):void
{
   trace ("works");
}


If you want to access the login button, itself (to change it's size, location, etc.), you can do something like this:

Code: Select all

import fl.controls.Button;
var loginButton:Button = loginBox.loginButton;
loginButton.height = 50;
loginBox.refreshView();


THANKS, BAX!!! :)

Return to “SmartFoxBits for SFS 1.x”

Who is online

Users browsing this forum: No registered users and 2 guests