Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Flex > Flex 2 & 3

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-28-2006, 06:31 PM   #1
Anunnakispirit
Registered User
 
Join Date: May 2006
Posts: 3
Exclamation List Component Flex 2 Beta 3 AS3

Flex 2 Beta 3 : ActionScript 3!
I am writing a chat client with audio/video support, and I'm having a bit of a problem adding users to the list component. After alot of confusion I managed to actually get them to add to the list using an array. But when a user joins the room, it shows all the nicknames again. For Example. I join as Guest1, Guest 1 gets added to the list, then I join under another name e.g Guest2; on the Guest1 client it displays Guest1, Guest1, Guest2...Which says to me, it has added the array when they join, but then it fetches the details again and adds them to the list ontop of the other. There must be a way to refresh the list, like remove the values and readd the array items. I'm not sure how, and I've only been doing actionscript for two weeks. (Also I apologise if there was another thread on this, I did search, and looked through about 5 pages of returned search results but none were particularly useful to what I'm doing) Please help me if you can, thanks!
Code:
//This is at the top of the code where myarray is defined as an array
public var myarray:Array =[""];
[Bindable]
public var collection:ArrayCollection = new ArrayCollection();

//this is an event listener for users_so:SharedObject;
private function UserGetSync(event:SyncEvent):void
	{
                    //Create a new array
	var collection:ArrayCollection=new ArrayCollection(myarray);
	      for(var i:* in users_so.data) {
                  //users_so.data[i] is the nickname retrieved from FMS     
	           if(users_so.data[i]!=null) {
 //add the retrieved nickname from user_so.data[i] to the array
 //There should be something here to refresh the NickList before adding users so it don't list on top of the last listing(which is where my problem lies)
	               collection.addItem(users_so.data[i]);
	               NickList.dataProvider=collection; 
	          }
	}
Anunnakispirit is offline   Reply With Quote
Old 05-29-2006, 01:34 PM   #2
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

The problem comes from 'myarray' not being refreshed.

Basically you ArrayCollections is made up of 'myarray', but you just keep adding to 'myarray' and therefore get duplicates.

Try
Code:
//This is at the top of the code where myarray is defined as an array
public var myarray:Array;

//this is an event listener for users_so:SharedObject;
private function UserGetSync( event:SyncEvent ):void
{
        // Create a new Array
        myarray = new Array();
        
        // Create new local ArrayCollection
        var collection:ArrayCollection=new ArrayCollection( myarray );

        for( var i:* in users_so.data )
        {
                //users_so.data[i] is the nickname retrieved from FMS     
	   if( users_so.data[i] != null )
                {
                        // Add the retrieved nickname from user_so.data[i]
                        // to the ArrayCollection
	           collection.addItem( users_so.data[ i ] );
                }
        }
        // Add ArrayCollection to List
        NickList.dataProvider=collection;
}
Tink is offline   Reply With Quote
Old 05-29-2006, 06:25 PM   #3
Anunnakispirit
Registered User
 
Join Date: May 2006
Posts: 3
Default

Thanks alot Tink, that worked great, but sadly I've run into another problem with actually allowing people to chat. I have webcam/audio and the nicklist working fine(some how lol) but now I'm not sure where I get the details from, I've looked through many examples in AS2 but flex examples seem to be a bit scarce, and as I'm new to actionscript I get a bit confused in the conversion process.

In my main.asc I have this
Code:
application.onConnect = function(newClient, name)
{
	// Make this new client's name the user's name
	newClient.name = name;
	
	// Create a unique ID for this user while incrementing the
	// application.nextID.
	newClient.id = "u" + application.nextId++;
	
	// Update the 'users_so' shared object with the user's name
	application.users_so.setProperty(newClient.name, name);
	
	// Accept the client's connection
 	application.acceptConnection(newClient);
	
	// Call the client function 'setHistory,' and pass 
	// the initial history
 	newClient.call("setHistory", null, application.history);

	// The client will call this function to get the server
	// to accept the message, add the user's name to it, and
	// send it back out to all connected clients.
	newClient.msgFromClient = function(msg) {	
		msg = this.name + ": " + msg + "\n";
		application.history += msg;
		application.users_so.send("msgFromSrvr", msg);
	}
}
which was taken from the FMS developer page. Here is the code for getting the message from the server in actionscript 2 I guess.
Code:
		
users_so.msgFromSrvr = function(msg) {
	
			_root.History.text += msg;
			_root.History.scroll = _root.History.maxscroll;
			historyScroll.setScrollTarget(history);
			historyScroll.setScrollPosition(_root.History.maxscroll);
		}
	}
basically what I need to know is howto get msgFromSrvr with the users_so object in actionscript3 in flex, it's a bit confusing for me, but I'm trying my best to work it out. I tried users_so.msgFromSrvr and it errored please help!
Anunnakispirit is offline   Reply With Quote
Old 06-14-2006, 02:09 PM   #4
Pratik123
Registered User
 
Join Date: Jun 2006
Posts: 1
Default

Oh greate that u reached to make chat application with audio, video and text in ActionScript. I want to help you. But you i want to know the all codes for that...
Pratik123 is offline   Reply With Quote
Old 06-20-2006, 10:39 AM   #5
nawin_g
Registered User
 
Join Date: Jun 2006
Posts: 1
Default plz mail me the code

hey Anunnakisprit,

i am also running thru the same problem (converting code from AS2 to AS3).

can you plz mail me your code coz i am also working on a very similar project.

my mail id is : nawin_g@yahoo.com

tq,
nawin_g is offline   Reply With Quote
Old 10-10-2007, 05:57 PM   #6
mrmyers
Registered User
 
Join Date: Apr 2004
Posts: 13
Default

Quote:
Originally Posted by Anunnakispirit View Post
basically what I need to know is howto get msgFromSrvr with the users_so object in actionscript3 in flex, it's a bit confusing for me, but I'm trying my best to work it out. I tried users_so.msgFromSrvr and it errored please help!
Anunnakispirit,

Did you ever figure this one out? I am wrestling with the sam issue and have had no luck in finding documentation anywhere. Thank youfor your time and energy.

Nate
mrmyers is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Major Problems trying to capture "click" event in List component ManinBlaq Components 11 01-30-2007 08:12 PM
List Component Double-Click Fuzzplug Jones Components 3 04-18-2006 11:10 PM
Extending List Component actionscriptLearner Components 2 01-07-2006 12:46 AM
2 Part Question: Tooltips for List Component . Word Wrap for List Component FaceEraser Components 0 09-12-2005 02:31 PM
using the List component in my class?? dangerhotrod Components 5 11-18-2004 08:34 AM


All times are GMT. The time now is 02:08 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.