How to add smiley to chat application using Action Script 3 in Flash Professional

Posted by & filed under Action Script 3, ADOBE FLEX, Flash.

This may be simple task when someone give you this, But really some what difficult is there  while positioning smiley in the textfield. I had gone through Google none of them explained this.

Download sample files here.

Here is simple way I had tried to position the smiley in chat application at exact position, may it useful to you guys. Try this and let me know if you have any ideas about smiley positioning.

In this tutorial I getting text and smiley we had entered in the textbox and save it in a string variable. Then using split() method I split-ed that string   into text and smiley and saved it in array variable. Now you can get text and smiley separately using array index like.

str1[0]= hi every body

str1[1]=<img src=’eye.jpg’ vspace=’-20′ height=’40’ width=’40’/>

Now I added this ‘str1[0]= hi every body‘ in the TextField to know width of text to position the smiley in after the text. Then adjusting vspace and hspace property of img tag I positioned smiley at exact position.

To know various techniques for finding  text width of TextField refer my previous tutorial ‘how to find text width of TextField using ActionScript 3 in Flash professional’

How to add smiley to chat application in Action Script 3 Flash Professional
import flash.text.TextField;
import flash.display.MovieClip;
import flash.text.TextFormat;

	public class SmileyText extends MovieClip
		public function SmileyText()
			var txt:TextField= new TextField;
			var txt1:TextField= new TextField;
			var txt_format:TextFormat=new TextFormat;
			var str:String="hi every body <img src='eye.jpg' vspace='-20' height='40' width='40'/>";

			var str1=str.split('<img');
			var txt_width=txt1.textWidth;
			var str2:String="hi every body <img src='eye.jpg' vspace='-20' hspace='"+txt_width+"' height='40' width='40'/>";




Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts

If you want any of my script need to be customized according to your business requirement,

Please feel free to contact me [at] muni[at]

Note: But it will be charged based on your customization requirement

Get Updates, Scripts & Other Useful Resources to your Email

Join 10,000+ Happy Subscribers on feedburner. Click to Subscribe (We don't send spam)
Every Email Subsciber could have access to download 100+ demo scripts & all future scripts.

%d bloggers like this:

Get Instant Script Download Access!