Does anyone know how you would pass messsages to and from a window

my problem is connecting the JID to the window

when a messages comes in it would send it to a window

var popup = mx.managers.PopUpManager.createPopUp(_root, testWindowPopup, false, );

I wonder if you would have to search for which window first in a loop

I was thinking

if(popups[uniqueID] != null)

{

popups[uniqueID].deletePopUp();

} else {

popups[uniqueID] = popup;

debugTxt.text += popup;

}

Has anyone done this and has a code snippet? Thanks

Hi Dan,

I did similar things with javascript. Actually I needed to update existing windows or to create new windows, which is probably much simpler than your use case.

Maybe it helps a lot to set the “title” or the “id:” of the window like the JID or a hash value of the JID.

So you’'d have a simple check like “if popups[JID.hashCode()] …”

LG

Hello,

Does Flash support Hashing? That would be cool.

Hi,

I don’'t know about Flash, Java offers such a method.

It was just an idea to have unique names which match the JID instead of using the JID as id. If using the JID is not possible because the id must be a number or must not contain ‘’@’’, ‘’/’’, … then you could write your own simple and fast hashcode function.

LG

I made a simple function to do the job for XIFFIAN:

/*

  • This functions makes an object name out of a JID. We can add a prefixe to the generated name
    

*/

function generateObjectName(leJID,prefixe) {// b0ris@usuc.dyndns.org/xiff OR xiffian@conference.usuc.dyndns.org/b0ris

var correctName=replaceChar(leJID,"@","@AT@");

correctName=replaceChar(correctName,".","@");

correctName=replaceChar(correctName,"/","-");

var objectName=correctName;

if(prefixe==undefined)

return objectName;

else

return(prefixe*""*objectName);

};

function replaceChar(sth,charToChange,newChar){

var tmp=sth.split(charToChange);

return tmp.join(newChar);

}

/i

It works good and I don’'t have anymore problems for object naming.

I replace @ not because it’‘s a special character for flash (it isn’‘t) but because it’‘s an unused character in jabber logins, and there isn’‘t that much characters that can’'t be in a login name (for example, you should be able to create a ,-:)@jabber.org[/b] account, not a b@d.Login@jabber.org[/b] )

Hope it helped

PS:The idea to use a hashcode is a great idea. But I can’‘t apply it to XIFFIAN because I parse it back to window title! and most hashcodes aren’'t reversible.

Hi Romain,

to solve “I can’‘t … parse it back to window title! and most hashcodes aren’'t reversible.” you could use encode and decode base64 methods. But I think you want to have the JID in the window title.

LG

Yes, base64 encoding should work!

and an actionscript class is available… I haven’'t tested it yet, but it should be prettier than my functions anyway, my function give good results

the base64 class for Actionscript: http://ostermiller.org/Base64.as