Groups | Blog | Home
all groups > flash actionscript > april 2005 >

flash actionscript : Smiley displaying ..?


Mansi-Padma
4/28/2005 12:00:00 AM
Hi,

I am a student, I had seen may chat application on flash. so, we decided to do
a chat as cariculam project . can anybody please help me how to display smiley
on chat.
It will be a great help for me if provided with a sample code.
Please help me.....

thanks,
Mansi

tomeanand NO[at]SPAM hotmail.com
4/28/2005 12:00:00 AM
hi Mansi

where you want to display smiley ??
be some more clear.

Mansi-Padma
4/28/2005 12:00:00 AM
Hi Anand,

I want to display the smiley on a textbox along with message just like,
Anand : Hello :)- how are u :(-

Flashkernel
4/28/2005 12:00:00 AM
Use html formatting for this.
You wil be using dynamic text for displaying the chat text (i suppose).
Enable the "render text as html" option. and use html tag <img> to add the
smiley icon inside the text.
e.g.
chat_txt.htmlText="<html>Hello<img src='smiley'>Mansi</html>";
Flashkernel
4/28/2005 12:00:00 AM
Flash documentation has to say this about img tag.
"The <img> tag lets you embed external JPEG files, SWF files, and movie clips
inside text fields and TextArea component instances. Text automatically flows
around images you embed in text fields or components. This tag is supported
only in dynamic and input text fields that are multiline and wrap their text. "
Mansi-Padma
4/28/2005 12:00:00 AM
Hi Anand,

I tried chat_txt.htmlText="<html>Hello<img src='smiley'>Mansi</html>";

It should come like - Hello :) Mansi
i got like - HelloMansi
:)

can you give some more help to allign the smiley like - Hello :) Mansi

Tanks
Mansi
Flashkernel
4/28/2005 12:00:00 AM
Hi Mansi,

This seems to be a bug/shortcoming of flash. Documentation says this
"In general, an image embedded in a text field appears on the
line following the <img> tag. However, when the <img> tag is the first
character in the text field, the image appears on the first line of the text
field."

By the way i'm not Anand.
tomeanand NO[at]SPAM hotmail.com
4/28/2005 12:00:00 AM
Hi mansi

this way you can do. but you need to write some custom methods to get the
length of the word before the smily.. because you have a chat application

just try this out..


var helo = "hello";
var smily_width = 25

man.htmlText = helo+"<img src='smilee' vspace='-17' align='center'
hspace='"+(smily_width+helo.length)+"'>"+putSpace(6)+"Mr Xyz abc";
man.border = true;
function putSpace(cnt:Number):String {
var ret_str:String = new String("");
for (var i=0; i<cnt; i++) {
ret_str +=" ";
}
return ret_str;
}

Mansi-Padma
4/28/2005 12:00:00 AM
Hi Anand,

It is working fine :). Here i think we hardcode the "hspace value". can u
please help me to find the occurance fo smiley dyanamically. ie, if somebody
not entered the smiley. Like,

1. Anand : hello :) How are u?
2. Mansi : Fine :)
3. Mansi : What about you?
4. Anand : not bad :(

see, in line no: 3 no smile is there
how can i dyanamically calculate the occurance of smiley.
Expecting valuable help.

Hi Flashkernel,

sorry for that. Thanks for the valuable help you are giving.

Thanks,
Mansi

tomeanand NO[at]SPAM hotmail.com
4/28/2005 12:00:00 AM
Hi manasi

you will insert smily only after an event right? (the user clicking of draging
or droping). at that point of time you can find .. and the hspace value is now
like this
hspace='"+(smily_width+helo.length)
smily width you can hardcode because you are gonna put all smily icons
instead of variable.lenght (helo) you can take the existing length of the
text when the use is clicking on the smily icon
something like this
smilyIcon_btn.onPress = function() {
var space = man.text.length;
man.htmlText += +"<img src='smilee' vspace='-17' align='center'
hspace='"+(smily_width+space)+"'>";
};

try out ...

Anand

Mansi-Padma
5/2/2005 12:00:00 AM
Hi Anand,

Its working fine, but smiley is not alligned properly. ie, if i need to show
hello :) then, i might come he:)llo or it may overlap the characters. can you
please help me to allign the smiley properly?

thanks,
Mansi
AddThis Social Bookmark Button